Changeset 51451
- Timestamp:
- 07/17/2021 10:36:52 AM (3 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r51331 r51451 373 373 static::assertFalse( is_iterable( $actual ), $message ); 374 374 } 375 376 /** 377 * Asserts that a string haystack contains a needle. 378 * 379 * This method has been backported from a more recent PHPUnit version, 380 * as tests running on PHP 5.6 use PHPUnit 5.7.x. 381 * 382 * @since 5.9.0 383 * 384 * @param string $needle The string to search for. 385 * @param string $haystack The string to treat as the haystack. 386 * @param string $message Optional. Message to display when the assertion fails. 387 */ 388 public static function assertStringContainsString( $needle, $haystack, $message = '' ) { 389 static::assertContains( $needle, $haystack, $message ); 390 } 391 392 /** 393 * Asserts that a string haystack does not contain a needle. 394 * 395 * This method has been backported from a more recent PHPUnit version, 396 * as tests running on PHP 5.6 use PHPUnit 5.7.x. 397 * 398 * @since 5.9.0 399 * 400 * @param string $needle The string to search for. 401 * @param string $haystack The string to treat as the haystack. 402 * @param string $message Optional. Message to display when the assertion fails. 403 */ 404 public static function assertStringNotContainsString( $needle, $haystack, $message = '' ) { 405 static::assertNotContains( $needle, $haystack, $message ); 406 } 375 407 } -
trunk/tests/phpunit/tests/ajax/Autosave.php
r51450 r51451 80 80 // Check that the edit happened. 81 81 $post = get_post( self::$post_id ); 82 $this->assert NotFalse( strpos( $post->post_content, $md5 ));82 $this->assertStringContainsString( $md5, $post->post_content ); 83 83 } 84 84 … … 126 126 // Check that the original post was NOT edited. 127 127 $post = get_post( self::$post_id ); 128 $this->assert False( strpos( $post->post_content, $md5 ));128 $this->assertStringNotContainsString( $md5, $post->post_content ); 129 129 130 130 // Check if the autosave post was created. 131 131 $autosave = wp_get_post_autosave( self::$post_id, get_current_user_id() ); 132 132 $this->assertNotEmpty( $autosave ); 133 $this->assert NotFalse( strpos( $autosave->post_content, $md5 ));133 $this->assertStringContainsString( $md5, $autosave->post_content ); 134 134 } 135 135 -
trunk/tests/phpunit/tests/image/intermediateSize.php
r51415 r51451 107 107 // Test for the expected string because the array will by definition 108 108 // return with the correct height and width attributes. 109 $this->assert True( strpos( $image['file'], '330x220' ) > 0);109 $this->assertStringContainsString( '330x220', $image['file'] ); 110 110 } 111 111 … … 129 129 // Test for the expected string because the array will by definition 130 130 // return with the correct height and width attributes. 131 $this->assert True( strpos( $image['file'], '330x220' ) > 0);131 $this->assertStringContainsString( '330x220', $image['file'] ); 132 132 } 133 133 … … 152 152 // Test for the expected string because the array will by definition 153 153 // return with the correct height and width attributes. 154 $this->assert True( strpos( $image['file'], '450x300' ) > 0);154 $this->assertStringContainsString( '450x300', $image['file'] ); 155 155 } 156 156 … … 202 202 // Test for the expected string because the array will by definition 203 203 // return with the correct height and width attributes. 204 $this->assert True( strpos( $image['file'], $image_w . 'x' . $image_h ) > 0);204 $this->assertStringContainsString( $image_w . 'x' . $image_h, $image['file'] ); 205 205 } 206 206 … … 231 231 // Test for the expected string because the array will by definition 232 232 // return with the correct height and width attributes. 233 $this->assert True( strpos( $image['file'], $image_w . 'x' . $image_h ) > 0);233 $this->assertStringContainsString( $image_w . 'x' . $image_h, $image['file'] ); 234 234 } 235 235 … … 256 256 $image = image_get_intermediate_size( $id, array( 0, $height ) ); 257 257 258 $this->assert True( strpos( $image['file'], $width . 'x' . $height ) > 0);258 $this->assertStringContainsString( $width . 'x' . $height, $image['file'] ); 259 259 } 260 260 … … 274 274 275 275 // We should get the 'test-size' file and not the thumbnail. 276 $this->assert True( strpos( $image['file'], '200x100' ) > 0);276 $this->assertStringContainsString( '200x100', $image['file'] ); 277 277 } 278 278 -
trunk/tests/phpunit/tests/mail.php
r50610 r51451 82 82 // We need some better assertions here but these catch the failure for now. 83 83 $this->assertSameIgnoreEOL( $body, $mailer->get_sent()->body ); 84 $this->assert True( strpos( iconv_mime_decode_headers( ( $mailer->get_sent()->header ) )['Content-Type'][0], 'boundary="----=_Part_4892_25692638.1192452070893"' ) > 0);85 $this->assert True( strpos( $mailer->get_sent()->header, 'charset=' ) > 0);84 $this->assertStringContainsString( 'boundary="----=_Part_4892_25692638.1192452070893"', iconv_mime_decode_headers( ( $mailer->get_sent()->header ) )['Content-Type'][0] ); 85 $this->assertStringContainsString( 'charset=', $mailer->get_sent()->header ); 86 86 } 87 87 … … 191 191 192 192 $mailer = tests_retrieve_phpmailer_instance(); 193 $this->assert True( strpos( $mailer->get_sent()->header, $expected ) > 0);193 $this->assertStringContainsString( $expected, $mailer->get_sent()->header ); 194 194 } 195 195 … … 207 207 208 208 $mailer = tests_retrieve_phpmailer_instance(); 209 $this->assert True( strpos( $mailer->get_sent()->header, $expected ) > 0);209 $this->assertStringContainsString( $expected, $mailer->get_sent()->header ); 210 210 } 211 211 … … 223 223 224 224 $mailer = tests_retrieve_phpmailer_instance(); 225 $this->assert True( strpos( $mailer->get_sent()->header, $expected ) > 0);225 $this->assertStringContainsString( $expected, $mailer->get_sent()->header ); 226 226 } 227 227 … … 239 239 240 240 $mailer = tests_retrieve_phpmailer_instance(); 241 $this->assert True( strpos( $mailer->get_sent()->header, $expected ) > 0);241 $this->assertStringContainsString( $expected, $mailer->get_sent()->header ); 242 242 } 243 243 … … 255 255 256 256 $mailer = tests_retrieve_phpmailer_instance(); 257 $this->assert True( strpos( $mailer->get_sent()->header, $expected ) > 0);257 $this->assertStringContainsString( $expected, $mailer->get_sent()->header ); 258 258 } 259 259 … … 271 271 272 272 $mailer = tests_retrieve_phpmailer_instance(); 273 $this->assert True( strpos( $mailer->get_sent()->header, $expected ) > 0);273 $this->assertStringContainsString( $expected, $mailer->get_sent()->header ); 274 274 } 275 275 -
trunk/tests/phpunit/tests/media.php
r51415 r51451 1655 1655 // Test to confirm all sources in the array include the same edit hash. 1656 1656 foreach ( $sizes as $size ) { 1657 $this->assert NotFalse( strpos( $size, $hash ));1657 $this->assertStringContainsString( $hash, $size ); 1658 1658 } 1659 1659 } … … 2231 2231 $this->assertFalse( wp_calculate_image_srcset( $size_array, $full_src, $image_meta ) ); 2232 2232 // Intermediate sized GIFs should not include the full size in the srcset. 2233 $this->assert False( strpos( wp_calculate_image_srcset( $size_array, $large_src, $image_meta ), $full_src) );2233 $this->assertStringNotContainsString( $full_src, wp_calculate_image_srcset( $size_array, $large_src, $image_meta ) ); 2234 2234 } 2235 2235 -
trunk/tests/phpunit/tests/oembed/template.php
r50441 r51451 33 33 $doc = new DOMDocument(); 34 34 $this->assertTrue( $doc->loadHTML( $actual ) ); 35 $this->assert False( strpos( $actual, 'That embed can’t be found.' ));36 $this->assert NotFalse( strpos( $actual, 'Hello World' ));35 $this->assertStringNotContainsString( 'That embed can’t be found.', $actual ); 36 $this->assertStringContainsString( 'Hello World', $actual ); 37 37 } 38 38 … … 65 65 $doc = new DOMDocument(); 66 66 $this->assertTrue( $doc->loadHTML( $actual ) ); 67 $this->assert False( strpos( $actual, 'That embed can’t be found.' ));68 $this->assert NotFalse( strpos( $actual, 'Hello World' ));69 $this->assert NotFalse( strpos( $actual, 'canola.jpg' ));67 $this->assertStringNotContainsString( 'That embed can’t be found.', $actual ); 68 $this->assertStringContainsString( 'Hello World', $actual ); 69 $this->assertStringContainsString( 'canola.jpg', $actual ); 70 70 } 71 71 … … 82 82 $doc = new DOMDocument(); 83 83 $this->assertTrue( $doc->loadHTML( $actual ) ); 84 $this->assert NotFalse( strpos( $actual, 'That embed can’t be found.' ));84 $this->assertStringContainsString( 'That embed can’t be found.', $actual ); 85 85 } 86 86 … … 109 109 $doc = new DOMDocument(); 110 110 $this->assertTrue( $doc->loadHTML( $actual ) ); 111 $this->assert False( strpos( $actual, 'That embed can’t be found.' ));112 $this->assert NotFalse( strpos( $actual, 'Hello World' ));113 $this->assert NotFalse( strpos( $actual, 'canola.jpg' ));111 $this->assertStringNotContainsString( 'That embed can’t be found.', $actual ); 112 $this->assertStringContainsString( 'Hello World', $actual ); 113 $this->assertStringContainsString( 'canola.jpg', $actual ); 114 114 } 115 115 … … 134 134 $doc = new DOMDocument(); 135 135 $this->assertTrue( $doc->loadHTML( $actual ) ); 136 $this->assert NotFalse( strpos( $actual, 'That embed can’t be found.' ));136 $this->assertStringContainsString( 'That embed can’t be found.', $actual ); 137 137 } 138 138 … … 158 158 $doc = new DOMDocument(); 159 159 $this->assertTrue( $doc->loadHTML( $actual ) ); 160 $this->assert NotFalse( strpos( $actual, 'That embed can’t be found.' ));160 $this->assertStringContainsString( 'That embed can’t be found.', $actual ); 161 161 } 162 162 … … 181 181 $doc = new DOMDocument(); 182 182 $this->assertTrue( $doc->loadHTML( $actual ) ); 183 $this->assert NotFalse( strpos( $actual, 'That embed can’t be found.' ));183 $this->assertStringContainsString( 'That embed can’t be found.', $actual ); 184 184 } 185 185 … … 208 208 $doc = new DOMDocument(); 209 209 $this->assertTrue( $doc->loadHTML( $actual ) ); 210 $this->assert False( strpos( $actual, 'That embed can’t be found.' ));211 $this->assert NotFalse( strpos( $actual, 'Hello World' ));210 $this->assertStringNotContainsString( 'That embed can’t be found.', $actual ); 211 $this->assertStringContainsString( 'Hello World', $actual ); 212 212 } 213 213
Note: See TracChangeset
for help on using the changeset viewer.