Changeset 48937 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r48516 r48937 49 49 function test_img_caption_shortcode_added() { 50 50 global $shortcode_tags; 51 $this->assert Equals( 'img_caption_shortcode', $shortcode_tags['caption'] );52 $this->assert Equals( 'img_caption_shortcode', $shortcode_tags['wp_caption'] );51 $this->assertSame( 'img_caption_shortcode', $shortcode_tags['caption'] ); 52 $this->assertSame( 'img_caption_shortcode', $shortcode_tags['wp_caption'] ); 53 53 } 54 54 … … 63 63 function test_img_caption_shortcode_with_empty_params_but_content() { 64 64 $result = img_caption_shortcode( array(), $this->caption ); 65 $this->assert Equals( $this->caption, $result );65 $this->assertSame( $this->caption, $result ); 66 66 } 67 67 … … 73 73 74 74 $result = img_caption_shortcode( array(), $this->caption ); 75 $this->assert Equals( $this->alternate_caption, $result );75 $this->assertSame( $this->alternate_caption, $result ); 76 76 } 77 77 … … 93 93 $this->caption 94 94 ); 95 $this->assert Equals( $this->caption, $result );95 $this->assertSame( $this->caption, $result ); 96 96 } 97 97 … … 118 118 $this->caption 119 119 ); 120 $this->assert Equals( $this->caption, $result );120 $this->assertSame( $this->caption, $result ); 121 121 } 122 122 … … 129 129 ); 130 130 131 $this->assert Equals( 2, preg_match_all( '/wp-caption/', $result, $_r ) );132 $this->assert Equals( 1, preg_match_all( '/alignnone/', $result, $_r ) );133 $this->assert Equals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );131 $this->assertSame( 2, preg_match_all( '/wp-caption/', $result, $_r ) ); 132 $this->assertSame( 1, preg_match_all( '/alignnone/', $result, $_r ) ); 133 $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 134 134 135 135 if ( current_theme_supports( 'html5', 'caption' ) ) { 136 $this->assert Equals( 1, preg_match_all( '/width: 20/', $result, $_r ) );136 $this->assertSame( 1, preg_match_all( '/width: 20/', $result, $_r ) ); 137 137 } else { 138 $this->assert Equals( 1, preg_match_all( '/width: 30/', $result, $_r ) );138 $this->assertSame( 1, preg_match_all( '/width: 30/', $result, $_r ) ); 139 139 } 140 140 } … … 149 149 ) 150 150 ); 151 $this->assert Equals( 1, preg_match_all( '/wp-caption &myAlignment/', $result, $_r ) );152 $this->assert Equals( 1, preg_match_all( '/id="myId"/', $result, $_r ) );153 $this->assert Equals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );151 $this->assertSame( 1, preg_match_all( '/wp-caption &myAlignment/', $result, $_r ) ); 152 $this->assertSame( 1, preg_match_all( '/id="myId"/', $result, $_r ) ); 153 $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); 154 154 } 155 155 … … 162 162 ) 163 163 ); 164 $this->assert Equals( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) );164 $this->assertSame( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) ); 165 165 166 166 } … … 175 175 $our_preg = preg_quote( $this->html_content ); 176 176 177 $this->assert Equals( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) );177 $this->assertSame( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) ); 178 178 } 179 179 … … 186 186 $content_preg = preg_quote( $this->html_content ); 187 187 188 $this->assert Equals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );189 $this->assert Equals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );188 $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); 189 $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 190 190 } 191 191 … … 199 199 $content_preg = preg_quote( $this->html_content ); 200 200 201 $this->assert Equals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );202 $this->assert Equals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );201 $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); 202 $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 203 203 } 204 204 … … 212 212 $content_preg = preg_quote( $this->html_content ); 213 213 214 $this->assert Equals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) );215 $this->assert Equals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) );214 $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); 215 $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 216 216 } 217 217 … … 228 228 ); 229 229 230 $this->assert Equals( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) );230 $this->assertSame( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) ); 231 231 } 232 232 … … 246 246 247 247 $result = $wp_embed->autoembed( $content ); 248 $this->assert Equals( $content, $result );248 $this->assertSame( $content, $result ); 249 249 } 250 250 … … 268 268 269 269 $result = $wp_embed->autoembed( $content ); 270 $this->assert Equals( $content, $result );270 $this->assertSame( $content, $result ); 271 271 } 272 272 … … 334 334 $wp_embed = new Test_Autoembed; 335 335 336 $this->assert Equals( $wp_embed->autoembed( $content ), $result ? $result : $content );336 $this->assertSame( $wp_embed->autoembed( $content ), $result ? $result : $content ); 337 337 } 338 338 … … 351 351 $prepped = wp_prepare_attachment_for_js( $post ); 352 352 $this->assertInternalType( 'array', $prepped ); 353 $this->assert Equals( 0, $prepped['uploadedTo'] );354 $this->assert Equals( '', $prepped['mime'] );355 $this->assert Equals( '', $prepped['type'] );356 $this->assert Equals( '', $prepped['subtype'] );353 $this->assertSame( 0, $prepped['uploadedTo'] ); 354 $this->assertSame( '', $prepped['mime'] ); 355 $this->assertSame( '', $prepped['type'] ); 356 $this->assertSame( '', $prepped['subtype'] ); 357 357 // #21963, there will be a GUID always, so there will be a URL. 358 358 $this->assertNotEquals( '', $prepped['url'] ); 359 $this->assert Equals( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] );359 $this->assertSame( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] ); 360 360 361 361 // Fake a mime. 362 362 $post->post_mime_type = 'image/jpeg'; 363 363 $prepped = wp_prepare_attachment_for_js( $post ); 364 $this->assert Equals( 'image/jpeg', $prepped['mime'] );365 $this->assert Equals( 'image', $prepped['type'] );366 $this->assert Equals( 'jpeg', $prepped['subtype'] );364 $this->assertSame( 'image/jpeg', $prepped['mime'] ); 365 $this->assertSame( 'image', $prepped['type'] ); 366 $this->assertSame( 'jpeg', $prepped['subtype'] ); 367 367 368 368 // Fake a mime without a slash. See #WP22532. 369 369 $post->post_mime_type = 'image'; 370 370 $prepped = wp_prepare_attachment_for_js( $post ); 371 $this->assert Equals( 'image', $prepped['mime'] );372 $this->assert Equals( 'image', $prepped['type'] );373 $this->assert Equals( '', $prepped['subtype'] );371 $this->assertSame( 'image', $prepped['mime'] ); 372 $this->assertSame( 'image', $prepped['type'] ); 373 $this->assertSame( '', $prepped['subtype'] ); 374 374 375 375 // Test that if author is not found, we return "(no author)" as `display_name`. 376 376 // The previously used test post contains no author, so we can reuse it. 377 $this->assert Equals( '(no author)', $prepped['authorName'] );377 $this->assertSame( '(no author)', $prepped['authorName'] ); 378 378 379 379 // Test that if author has HTML entities in display_name, they're decoded correctly. … … 385 385 $post->post_author = $html_entity_author; 386 386 $prepped = wp_prepare_attachment_for_js( $post ); 387 $this->assert Equals( 'You & Me', $prepped['authorName'] );387 $this->assertSame( 'You & Me', $prepped['authorName'] ); 388 388 } 389 389 … … 429 429 430 430 // Test if boundaries are correct. 431 $this->assert Equals( '1TB', wp_convert_bytes_to_hr( $tb ) );432 $this->assert Equals( '1GB', wp_convert_bytes_to_hr( $gb ) );433 $this->assert Equals( '1MB', wp_convert_bytes_to_hr( $mb ) );434 $this->assert Equals( '1KB', wp_convert_bytes_to_hr( $kb ) );435 436 $this->assert Equals( '1 TB', size_format( $tb ) );437 $this->assert Equals( '1 GB', size_format( $gb ) );438 $this->assert Equals( '1 MB', size_format( $mb ) );439 $this->assert Equals( '1 KB', size_format( $kb ) );431 $this->assertSame( '1TB', wp_convert_bytes_to_hr( $tb ) ); 432 $this->assertSame( '1GB', wp_convert_bytes_to_hr( $gb ) ); 433 $this->assertSame( '1MB', wp_convert_bytes_to_hr( $mb ) ); 434 $this->assertSame( '1KB', wp_convert_bytes_to_hr( $kb ) ); 435 436 $this->assertSame( '1 TB', size_format( $tb ) ); 437 $this->assertSame( '1 GB', size_format( $gb ) ); 438 $this->assertSame( '1 MB', size_format( $mb ) ); 439 $this->assertSame( '1 KB', size_format( $kb ) ); 440 440 441 441 // Now some values around. … … 453 453 454 454 // Edge. 455 $this->assert Equals( '-1B', wp_convert_bytes_to_hr( -1 ) );456 $this->assert Equals( '0B', wp_convert_bytes_to_hr( 0 ) );455 $this->assertSame( '-1B', wp_convert_bytes_to_hr( -1 ) ); 456 $this->assertSame( '0B', wp_convert_bytes_to_hr( 0 ) ); 457 457 } 458 458 … … 523 523 $post_id = self::factory()->post->create( array( 'post_content' => $blob ) ); 524 524 $srcs = get_post_galleries_images( $post_id ); 525 $this->assert Equals( $srcs, array( $ids1_srcs, $ids2_srcs ) );525 $this->assertSame( $srcs, array( $ids1_srcs, $ids2_srcs ) ); 526 526 } 527 527 … … 673 673 $post_id = self::factory()->post->create( array( 'post_content' => $blob ) ); 674 674 $srcs = get_post_gallery_images( $post_id ); 675 $this->assert Equals( $srcs, $ids1_srcs );675 $this->assertSame( $srcs, $ids1_srcs ); 676 676 } 677 677 … … 722 722 723 723 $matches = get_media_embedded_in_content( $content, 'audio' ); 724 $this->assert Equals( array( $audio ), $matches );724 $this->assertSame( array( $audio ), $matches ); 725 725 726 726 $matches = get_media_embedded_in_content( $content, 'video' ); 727 $this->assert Equals( array( $video ), $matches );727 $this->assertSame( array( $video ), $matches ); 728 728 729 729 $matches = get_media_embedded_in_content( $content, 'object' ); 730 $this->assert Equals( array( $object ), $matches );730 $this->assertSame( array( $object ), $matches ); 731 731 732 732 $matches = get_media_embedded_in_content( $content, 'embed' ); 733 $this->assert Equals( array( $embed ), $matches );733 $this->assertSame( array( $embed ), $matches ); 734 734 735 735 $matches = get_media_embedded_in_content( $content, 'iframe' ); 736 $this->assert Equals( array( $iframe ), $matches );736 $this->assertSame( array( $iframe ), $matches ); 737 737 738 738 $matches = get_media_embedded_in_content( $content, $types ); 739 $this->assert Equals( $contents, $matches );739 $this->assertSame( $contents, $matches ); 740 740 } 741 741 … … 754 754 755 755 $matches1 = get_media_embedded_in_content( $content, array( 'audio', 'video' ) ); 756 $this->assert Equals( array( $audio, $video ), $matches1 );756 $this->assertSame( array( $audio, $video ), $matches1 ); 757 757 758 758 $reversed = $video . $audio; 759 759 $matches2 = get_media_embedded_in_content( $reversed, array( 'audio', 'video' ) ); 760 $this->assert Equals( array( $video, $audio ), $matches2 );760 $this->assertSame( array( $video, $audio ), $matches2 ); 761 761 } 762 762 … … 860 860 "http://domain.tld/wp-content/uploads/2013/12/xyz.mp4</a></video></div>\n"; 861 861 862 $this->assert Equals( $expected, $content );862 $this->assertSame( $expected, $content ); 863 863 } 864 864 … … 1017 1017 1018 1018 $this->assertArrayHasKey( 'test-size', $sizes ); 1019 $this->assert Equals( 200, $sizes['test-size']['width'] );1020 $this->assert Equals( 600, $sizes['test-size']['height'] );1019 $this->assertSame( 200, $sizes['test-size']['width'] ); 1020 $this->assertSame( 600, $sizes['test-size']['height'] ); 1021 1021 } 1022 1022 … … 1057 1057 1058 1058 $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; 1059 $this->assert Equals( $attachment_id, attachment_url_to_postid( $image_url ) );1059 $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); 1060 1060 } 1061 1061 … … 1075 1075 1076 1076 $image_url = 'https://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; 1077 $this->assert Equals( $attachment_id, attachment_url_to_postid( $image_url ) );1077 $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); 1078 1078 } 1079 1079 … … 1103 1103 1104 1104 $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path_upper_case; 1105 $this->assert Equals( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) );1105 $this->assertSame( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) ); 1106 1106 } 1107 1107 … … 1119 1119 add_filter( 'upload_dir', array( $this, '_upload_dir' ) ); 1120 1120 $image_url = 'http://192.168.1.20.com/wp-content/uploads/' . $image_path; 1121 $this->assert Equals( $attachment_id, attachment_url_to_postid( $image_url ) );1121 $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); 1122 1122 remove_filter( 'upload_dir', array( $this, '_upload_dir' ) ); 1123 1123 } … … 1134 1134 $post_id = attachment_url_to_postid( '' ); 1135 1135 $this->assertInternalType( 'int', $post_id ); 1136 $this->assert Equals( 0, $post_id );1136 $this->assertSame( 0, $post_id ); 1137 1137 } 1138 1138 … … 1173 1173 wp_delete_attachment( $post_id ); 1174 1174 1175 $this->assert Equals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt );1175 $this->assertSame( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt ); 1176 1176 } 1177 1177 … … 1212 1212 wp_delete_attachment( $post_id ); 1213 1213 1214 $this->assert Equals( 'This is a test', $post->post_title );1214 $this->assertSame( 'This is a test', $post->post_title ); 1215 1215 } 1216 1216 … … 1229 1229 1230 1230 $result = $wp_embed->autoembed( $content ); 1231 $this->assert Equals( $content, $result );1231 $this->assertSame( $content, $result ); 1232 1232 } 1233 1233 … … 1245 1245 1246 1246 $result = $wp_embed->autoembed( $content ); 1247 $this->assert Equals( $content, $result );1247 $this->assertSame( $content, $result ); 1248 1248 } 1249 1249 … … 1279 1279 1280 1280 $result = apply_filters( 'the_content', $content ); 1281 $this->assert EqualsIgnoreEOL( $expected, $result );1281 $this->assertSameIgnoreEOL( $expected, $result ); 1282 1282 } 1283 1283 … … 1308 1308 1309 1309 $result = $wp_embed->autoembed( $content ); 1310 $this->assert Equals( $expected, $result );1310 $this->assertSame( $expected, $result ); 1311 1311 1312 1312 $content = <<<EOF … … 1322 1322 1323 1323 $result = $wp_embed->autoembed( $content ); 1324 $this->assert Equals( $content, $result );1324 $this->assertSame( $content, $result ); 1325 1325 1326 1326 remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); … … 1341 1341 ); 1342 1342 1343 $this->assert Equals( $expected, wp_get_attachment_image( self::$large_id ) );1343 $this->assertSame( $expected, wp_get_attachment_image( self::$large_id ) ); 1344 1344 } 1345 1345 … … 1361 1361 ); 1362 1362 1363 $this->assert Equals( $expected, wp_get_attachment_image( self::$large_id ) );1363 $this->assertSame( $expected, wp_get_attachment_image( self::$large_id ) ); 1364 1364 1365 1365 // Cleanup. … … 1385 1385 $image = wp_get_attachment_image_src( $attachment_id, 'thumbnail', false ); 1386 1386 1387 $this->assert Equals( $image[0], wp_get_attachment_image_url( $attachment_id ) );1387 $this->assertSame( $image[0], wp_get_attachment_image_url( $attachment_id ) ); 1388 1388 } 1389 1389 … … 1409 1409 $this->assertFalse( wp_get_attachment_caption( $post_id ) ); 1410 1410 1411 $this->assert Equals( $caption, wp_get_attachment_caption( $attachment_id ) );1411 $this->assertSame( $caption, wp_get_attachment_caption( $attachment_id ) ); 1412 1412 } 1413 1413 … … 1427 1427 ); 1428 1428 1429 $this->assert Equals( '', wp_get_attachment_caption( $attachment_id ) );1429 $this->assertSame( '', wp_get_attachment_caption( $attachment_id ) ); 1430 1430 } 1431 1431 … … 2388 2388 $attachment_id = wp_insert_attachment( $data, '', 0, true ); 2389 2389 $this->assertWPError( $attachment_id ); 2390 $this->assert Equals( 'invalid_date', $attachment_id->get_error_code() );2390 $this->assertSame( 'invalid_date', $attachment_id->get_error_code() ); 2391 2391 2392 2392 $attachment_id = wp_insert_attachment( $data, '', 0 ); … … 2407 2407 ); 2408 2408 2409 $this->assert Equals( 123, wp_get_media_creation_timestamp( $metadata ) );2409 $this->assertSame( 123, wp_get_media_creation_timestamp( $metadata ) ); 2410 2410 } 2411 2411 … … 2425 2425 ); 2426 2426 2427 $this->assert Equals( 1450978809, wp_get_media_creation_timestamp( $metadata ) );2427 $this->assertSame( 1450978809, wp_get_media_creation_timestamp( $metadata ) ); 2428 2428 } 2429 2429 … … 2445 2445 ); 2446 2446 2447 $this->assert Equals( 1450978805, wp_get_media_creation_timestamp( $metadata ) );2447 $this->assertSame( 1450978805, wp_get_media_creation_timestamp( $metadata ) ); 2448 2448 } 2449 2449 … … 2463 2463 ); 2464 2464 2465 $this->assert Equals( 1265680539, wp_get_media_creation_timestamp( $metadata ) );2465 $this->assertSame( 1265680539, wp_get_media_creation_timestamp( $metadata ) ); 2466 2466 } 2467 2467 … … 2478 2478 $metadata = wp_read_audio_metadata( $video ); 2479 2479 2480 $this->assert Equals( 1269120551, $metadata['created_timestamp'] );2480 $this->assertSame( 1269120551, $metadata['created_timestamp'] ); 2481 2481 } 2482 2482 … … 2488 2488 $metadata = wp_read_video_metadata( $video ); 2489 2489 2490 $this->assert Equals( 1269120551, $metadata['created_timestamp'] );2490 $this->assertSame( 1269120551, $metadata['created_timestamp'] ); 2491 2491 } 2492 2492 … … 2498 2498 $metadata = wp_read_video_metadata( $video ); 2499 2499 2500 $this->assert Equals( 1269120551, $metadata['created_timestamp'] );2500 $this->assertSame( 1269120551, $metadata['created_timestamp'] ); 2501 2501 } 2502 2502 … … 2508 2508 $metadata = wp_read_video_metadata( $video ); 2509 2509 2510 $this->assert Equals( 1269120551, $metadata['created_timestamp'] );2510 $this->assertSame( 1269120551, $metadata['created_timestamp'] ); 2511 2511 } 2512 2512 … … 2518 2518 $metadata = wp_read_video_metadata( $video ); 2519 2519 2520 $this->assert Equals( 1269120551, $metadata['created_timestamp'] );2520 $this->assertSame( 1269120551, $metadata['created_timestamp'] ); 2521 2521 } 2522 2522 … … 2970 2970 ) 2971 2971 ); 2972 $this->assert Equals( 2, substr_count( $actual, '.jpg' ) );2972 $this->assertSame( 2, substr_count( $actual, '.jpg' ) ); 2973 2973 2974 2974 // None: Does not link.
Note: See TracChangeset
for help on using the changeset viewer.