Changeset 52010 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r51816 r52010 57 57 } 58 58 59 function set_up() {59 public function set_up() { 60 60 parent::set_up(); 61 61 $this->caption = 'A simple caption.'; … … 77 77 } 78 78 79 function test_img_caption_shortcode_added() {79 public function test_img_caption_shortcode_added() { 80 80 global $shortcode_tags; 81 81 $this->assertSame( 'img_caption_shortcode', $shortcode_tags['caption'] ); … … 83 83 } 84 84 85 function test_img_caption_shortcode_with_empty_params() {85 public function test_img_caption_shortcode_with_empty_params() { 86 86 $result = img_caption_shortcode( array() ); 87 87 $this->assertSame( '', $result ); … … 91 91 * @ticket 33981 92 92 */ 93 function test_img_caption_shortcode_with_empty_params_but_content() {93 public function test_img_caption_shortcode_with_empty_params_but_content() { 94 94 $result = img_caption_shortcode( array(), $this->caption ); 95 95 $this->assertSame( $this->caption, $result ); … … 99 99 * @ticket 33981 100 100 */ 101 function test_img_caption_shortcode_short_circuit_filter() {102 add_filter( 'img_caption_shortcode', array( $this, ' _return_alt_caption' ) );101 public function test_img_caption_shortcode_short_circuit_filter() { 102 add_filter( 'img_caption_shortcode', array( $this, 'return_alt_caption' ) ); 103 103 104 104 $result = img_caption_shortcode( array(), $this->caption ); … … 109 109 * Filter used in test_img_caption_shortcode_short_circuit_filter() 110 110 */ 111 function _return_alt_caption() {111 public function return_alt_caption() { 112 112 return $this->alternate_caption; 113 113 } … … 116 116 * @ticket 33981 117 117 */ 118 function test_img_caption_shortcode_empty_width() {118 public function test_img_caption_shortcode_empty_width() { 119 119 $result = img_caption_shortcode( 120 120 array( … … 129 129 * @ticket 33981 130 130 */ 131 function test_img_caption_shortcode_empty_caption() {131 public function test_img_caption_shortcode_empty_caption() { 132 132 $result = img_caption_shortcode( 133 133 array( … … 141 141 * @ticket 33981 142 142 */ 143 function test_img_caption_shortcode_empty_caption_and_content() {143 public function test_img_caption_shortcode_empty_caption_and_content() { 144 144 $result = img_caption_shortcode( 145 145 array( … … 151 151 } 152 152 153 function test_img_caption_shortcode_with_old_format() {153 public function test_img_caption_shortcode_with_old_format() { 154 154 $result = img_caption_shortcode( 155 155 array( … … 170 170 } 171 171 172 function test_img_caption_shortcode_with_old_format_id_and_align() {172 public function test_img_caption_shortcode_with_old_format_id_and_align() { 173 173 $result = img_caption_shortcode( 174 174 array( … … 184 184 } 185 185 186 function test_img_caption_shortcode_with_old_format_and_class() {186 public function test_img_caption_shortcode_with_old_format_and_class() { 187 187 $result = img_caption_shortcode( 188 188 array( … … 196 196 } 197 197 198 function test_new_img_caption_shortcode_with_html_caption() {198 public function test_new_img_caption_shortcode_with_html_caption() { 199 199 $result = img_caption_shortcode( 200 200 array( … … 208 208 } 209 209 210 function test_new_img_caption_shortcode_new_format() {210 public function test_new_img_caption_shortcode_new_format() { 211 211 $result = img_caption_shortcode( 212 212 array( 'width' => 20 ), … … 220 220 } 221 221 222 function test_new_img_caption_shortcode_new_format_and_linked_image() {222 public function test_new_img_caption_shortcode_new_format_and_linked_image() { 223 223 $linked_image = "<a href='#'>{$this->img_content}</a>"; 224 224 $result = img_caption_shortcode( … … 233 233 } 234 234 235 function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() {235 public function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { 236 236 $linked_image = "<a href='#'>{$this->img_content}</a>"; 237 237 $result = img_caption_shortcode( … … 249 249 * @ticket 34595 250 250 */ 251 function test_img_caption_shortcode_has_aria_describedby() {251 public function test_img_caption_shortcode_has_aria_describedby() { 252 252 $result = img_caption_shortcode( 253 253 array( … … 261 261 } 262 262 263 function test_add_remove_oembed_provider() {263 public function test_add_remove_oembed_provider() { 264 264 wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); 265 265 $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); … … 270 270 * @ticket 23776 271 271 */ 272 function test_autoembed_empty() {272 public function test_autoembed_empty() { 273 273 global $wp_embed; 274 274 … … 284 284 * @group external-http 285 285 */ 286 function test_autoembed_no_paragraphs_around_urls() {286 public function test_autoembed_no_paragraphs_around_urls() { 287 287 global $wp_embed; 288 288 … … 303 303 } 304 304 305 function data_autoembed() {305 public function data_autoembed() { 306 306 return array( 307 307 … … 363 363 * @dataProvider data_autoembed 364 364 */ 365 function test_autoembed( $content, $result = null ) {365 public function test_autoembed( $content, $result = null ) { 366 366 $wp_embed = new Test_Autoembed; 367 367 … … 369 369 } 370 370 371 function test_wp_prepare_attachment_for_js() {371 public function test_wp_prepare_attachment_for_js() { 372 372 // Attachment without media. 373 373 $id = wp_insert_attachment( … … 423 423 * @ticket 38965 424 424 */ 425 function test_wp_prepare_attachment_for_js_without_image_sizes() {425 public function test_wp_prepare_attachment_for_js_without_image_sizes() { 426 426 // Create the attachement post. 427 427 $id = wp_insert_attachment( … … 454 454 * @expectedDeprecated wp_convert_bytes_to_hr 455 455 */ 456 function test_wp_convert_bytes_to_hr() {456 public function test_wp_convert_bytes_to_hr() { 457 457 $kb = 1024; 458 458 $mb = $kb * 1024; … … 492 492 * @ticket 22960 493 493 */ 494 function test_get_attached_images() {494 public function test_get_attached_images() { 495 495 $post_id = self::factory()->post->create(); 496 496 $attachment_id = self::factory()->attachment->create_object( … … 510 510 * @ticket 22960 511 511 */ 512 function test_post_galleries_images() {512 public function test_post_galleries_images() { 513 513 $ids1 = array(); 514 514 $ids1_srcs = array(); … … 561 561 * @ticket 39304 562 562 */ 563 function test_post_galleries_images_without_global_post() {563 public function test_post_galleries_images_without_global_post() { 564 564 // Set up an unattached image. 565 565 $this->factory->attachment->create_object( … … 586 586 * @ticket 39304 587 587 */ 588 function test_post_galleries_ignores_global_post() {588 public function test_post_galleries_ignores_global_post() { 589 589 $global_post_id = $this->factory->post->create( 590 590 array( … … 621 621 * @ticket 39304 622 622 */ 623 function test_post_galleries_respects_id_attrs() {623 public function test_post_galleries_respects_id_attrs() { 624 624 $post_id = $this->factory->post->create( 625 625 array( … … 660 660 * @ticket 22960 661 661 */ 662 function test_post_gallery_images() {662 public function test_post_gallery_images() { 663 663 $ids1 = array(); 664 664 $ids1_srcs = array(); … … 708 708 } 709 709 710 function test_get_media_embedded_in_content() {710 public function test_get_media_embedded_in_content() { 711 711 $object = <<<OBJ 712 712 <object src="this" data="that"> … … 772 772 } 773 773 774 function test_get_media_embedded_in_content_order() {774 public function test_get_media_embedded_in_content_order() { 775 775 $audio = <<<AUDIO 776 776 <audio preload="none"> … … 796 796 * @ticket 35367 797 797 */ 798 function test_wp_audio_shortcode_with_empty_params() {798 public function test_wp_audio_shortcode_with_empty_params() { 799 799 $this->assertNull( wp_audio_shortcode( array() ) ); 800 800 } … … 803 803 * @ticket 35367 804 804 */ 805 function test_wp_audio_shortcode_with_bad_attr() {805 public function test_wp_audio_shortcode_with_bad_attr() { 806 806 $this->assertSame( 807 807 '<a class="wp-embedded-audio" href="https://example.com/foo.php">https://example.com/foo.php</a>', … … 817 817 * @ticket 35367 818 818 */ 819 function test_wp_audio_shortcode_attributes() {819 public function test_wp_audio_shortcode_attributes() { 820 820 $actual = wp_audio_shortcode( 821 821 array( … … 853 853 * Test [video] shortcode processing 854 854 */ 855 function test_video_shortcode_body() {855 public function test_video_shortcode_body() { 856 856 $width = 720; 857 857 $height = 480; … … 899 899 * @depends test_video_shortcode_body 900 900 */ 901 function test_wp_video_shortcode_with_empty_params() {901 public function test_wp_video_shortcode_with_empty_params() { 902 902 $this->assertNull( wp_video_shortcode( array() ) ); 903 903 } … … 907 907 * @depends test_video_shortcode_body 908 908 */ 909 function test_wp_video_shortcode_with_bad_attr() {909 public function test_wp_video_shortcode_with_bad_attr() { 910 910 $this->assertSame( 911 911 '<a class="wp-embedded-video" href="https://example.com/foo.php">https://example.com/foo.php</a>', … … 922 922 * @depends test_video_shortcode_body 923 923 */ 924 function test_wp_video_shortcode_attributes() {924 public function test_wp_video_shortcode_attributes() { 925 925 $actual = wp_video_shortcode( 926 926 array( … … 964 964 * @depends test_video_shortcode_body 965 965 */ 966 function test_wp_video_shortcode_youtube_remove_feature() {966 public function test_wp_video_shortcode_youtube_remove_feature() { 967 967 $actual = wp_video_shortcode( 968 968 array( … … 978 978 * @depends test_video_shortcode_body 979 979 */ 980 function test_wp_video_shortcode_youtube_force_ssl() {980 public function test_wp_video_shortcode_youtube_force_ssl() { 981 981 $actual = wp_video_shortcode( 982 982 array( … … 992 992 * @depends test_video_shortcode_body 993 993 */ 994 function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() {994 public function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() { 995 995 $actual = wp_video_shortcode( 996 996 array( … … 1007 1007 * @depends test_video_shortcode_body 1008 1008 */ 1009 function test_wp_video_shortcode_vimeo_adds_loop() {1009 public function test_wp_video_shortcode_vimeo_adds_loop() { 1010 1010 $actual = wp_video_shortcode( 1011 1011 array( … … 1021 1021 * @depends test_video_shortcode_body 1022 1022 */ 1023 function test_wp_video_shortcode_vimeo_force_adds_loop_true() {1023 public function test_wp_video_shortcode_vimeo_force_adds_loop_true() { 1024 1024 $actual = wp_video_shortcode( 1025 1025 array( … … 1035 1035 * @ticket 26768 1036 1036 */ 1037 function test_add_image_size() {1037 public function test_add_image_size() { 1038 1038 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1039 1039 … … 1056 1056 * @ticket 26768 1057 1057 */ 1058 function test_remove_image_size() {1058 public function test_remove_image_size() { 1059 1059 add_image_size( 'test-size', 200, 600 ); 1060 1060 $this->assertTrue( has_image_size( 'test-size' ) ); … … 1066 1066 * @ticket 26951 1067 1067 */ 1068 function test_has_image_size() {1068 public function test_has_image_size() { 1069 1069 add_image_size( 'test-size', 200, 600 ); 1070 1070 $this->assertTrue( has_image_size( 'test-size' ) ); … … 1077 1077 * @ticket 30346 1078 1078 */ 1079 function test_attachment_url_to_postid() {1079 public function test_attachment_url_to_postid() { 1080 1080 $image_path = '2014/11/' . $this->img_name; 1081 1081 $attachment_id = self::factory()->attachment->create_object( … … 1095 1095 * @ticket 33109 1096 1096 */ 1097 function test_attachment_url_to_postid_with_different_scheme() {1097 public function test_attachment_url_to_postid_with_different_scheme() { 1098 1098 $image_path = '2014/11/' . $this->img_name; 1099 1099 $attachment_id = self::factory()->attachment->create_object( … … 1113 1113 * @ticket 39768 1114 1114 */ 1115 function test_attachment_url_to_postid_should_be_case_sensitive() {1115 public function test_attachment_url_to_postid_should_be_case_sensitive() { 1116 1116 $image_path_lower_case = '2014/11/' . $this->img_name; 1117 1117 $attachment_id_lower_case = self::factory()->attachment->create_object( … … 1138 1138 } 1139 1139 1140 function test_attachment_url_to_postid_filtered() {1140 public function test_attachment_url_to_postid_filtered() { 1141 1141 $image_path = '2014/11/' . $this->img_name; 1142 1142 $attachment_id = self::factory()->attachment->create_object( … … 1149 1149 ); 1150 1150 1151 add_filter( 'upload_dir', array( $this, ' _upload_dir' ) );1151 add_filter( 'upload_dir', array( $this, 'upload_dir' ) ); 1152 1152 $image_url = 'http://192.168.1.20.com/wp-content/uploads/' . $image_path; 1153 1153 $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); 1154 remove_filter( 'upload_dir', array( $this, ' _upload_dir' ) );1155 } 1156 1157 function _upload_dir( $dir ) {1154 remove_filter( 'upload_dir', array( $this, 'upload_dir' ) ); 1155 } 1156 1157 public function upload_dir( $dir ) { 1158 1158 $dir['baseurl'] = 'http://192.168.1.20.com/wp-content/uploads'; 1159 1159 return $dir; … … 1163 1163 * @ticket 31044 1164 1164 */ 1165 function test_attachment_url_to_postid_with_empty_url() {1165 public function test_attachment_url_to_postid_with_empty_url() { 1166 1166 $post_id = attachment_url_to_postid( '' ); 1167 1167 $this->assertIsInt( $post_id ); … … 1250 1250 * @ticket 33016 1251 1251 */ 1252 function test_multiline_cdata() {1252 public function test_multiline_cdata() { 1253 1253 global $wp_embed; 1254 1254 … … 1267 1267 * @ticket 33016 1268 1268 */ 1269 function test_multiline_comment() {1269 public function test_multiline_comment() { 1270 1270 global $wp_embed; 1271 1271 … … 1286 1286 * @group external-http 1287 1287 */ 1288 function test_multiline_comment_with_embeds() {1288 public function test_multiline_comment_with_embeds() { 1289 1289 $content = <<<EOF 1290 1290 Start. … … 1319 1319 * @ticket 33016 1320 1320 */ 1321 function filter_wp_embed_shortcode_custom( $content, $url ) {1321 public function filter_wp_embed_shortcode_custom( $content, $url ) { 1322 1322 if ( 'https://www.example.com/?video=1' === $url ) { 1323 1323 $content = '@embed URL was replaced@'; … … 1331 1331 * @group external-http 1332 1332 */ 1333 function test_oembed_explicit_media_link() {1333 public function test_oembed_explicit_media_link() { 1334 1334 global $wp_embed; 1335 1335 add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 ); … … 1368 1368 * @ticket 34635 1369 1369 */ 1370 function test_wp_get_attachment_image_defaults() {1370 public function test_wp_get_attachment_image_defaults() { 1371 1371 $image = image_downsize( self::$large_id, 'thumbnail' ); 1372 1372 $expected = sprintf( … … 1383 1383 * @ticket 50801 1384 1384 */ 1385 function test_wp_get_attachment_image_filter_output() {1385 public function test_wp_get_attachment_image_filter_output() { 1386 1386 $image = image_downsize( self::$large_id, 'thumbnail' ); 1387 1387 $expected = 'Override wp_get_attachment_image'; … … 1394 1394 } 1395 1395 1396 function filter_wp_get_attachment_image() {1396 public function filter_wp_get_attachment_image() { 1397 1397 return 'Override wp_get_attachment_image'; 1398 1398 } … … 1403 1403 * @ticket 34635 1404 1404 */ 1405 function test_wp_get_attachment_image_with_alt() {1405 public function test_wp_get_attachment_image_with_alt() { 1406 1406 // Add test alt metadata. 1407 1407 update_post_meta( self::$large_id, '_wp_attachment_image_alt', 'Some very clever alt text', true ); … … 1424 1424 * @ticket 33878 1425 1425 */ 1426 function test_wp_get_attachment_image_url() {1426 public function test_wp_get_attachment_image_url() { 1427 1427 $this->assertFalse( wp_get_attachment_image_url( 0 ) ); 1428 1428 … … 1445 1445 * @ticket 12235 1446 1446 */ 1447 function test_wp_get_attachment_caption() {1447 public function test_wp_get_attachment_caption() { 1448 1448 $this->assertFalse( wp_get_attachment_caption( 0 ) ); 1449 1449 … … 1469 1469 * @ticket 12235 1470 1470 */ 1471 function test_wp_get_attachment_caption_empty() {1471 public function test_wp_get_attachment_caption_empty() { 1472 1472 $post_id = self::factory()->post->create(); 1473 1473 $attachment_id = self::factory()->attachment->create_object( … … 1487 1487 * Helper function to get image size array from size "name". 1488 1488 */ 1489 function _get_image_size_array_from_meta( $image_meta, $size_name ) {1489 private function get_image_size_array_from_meta( $image_meta, $size_name ) { 1490 1490 $array = false; 1491 1491 … … 1508 1508 * Helper function to move the src image to the first position in the expected srcset string. 1509 1509 */ 1510 function _src_first( $srcset, $src_url, $src_width ) {1510 private function src_first( $srcset, $src_url, $src_width ) { 1511 1511 $src_string = $src_url . ' ' . $src_width . 'w'; 1512 1512 $src_not_first = ', ' . $src_string; … … 1524 1524 * @requires function imagejpeg 1525 1525 */ 1526 function test_wp_calculate_image_srcset() {1526 public function test_wp_calculate_image_srcset() { 1527 1527 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1528 1528 … … 1554 1554 foreach ( $intermediates as $int ) { 1555 1555 $image_url = wp_get_attachment_image_url( self::$large_id, $int ); 1556 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, $int );1556 $size_array = $this->get_image_size_array_from_meta( $image_meta, $int ); 1557 1557 1558 1558 if ( 'full' === $int ) { … … 1563 1563 } 1564 1564 1565 $expected_srcset = $this-> _src_first( $_expected, $image_url, $size_array[0] );1565 $expected_srcset = $this->src_first( $_expected, $image_url, $size_array[0] ); 1566 1566 $this->assertSame( $expected_srcset, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); 1567 1567 } … … 1572 1572 * @requires function imagejpeg 1573 1573 */ 1574 function test_wp_calculate_image_srcset_no_date_uploads() {1574 public function test_wp_calculate_image_srcset_no_date_uploads() { 1575 1575 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1576 1576 … … 1606 1606 1607 1607 foreach ( $intermediates as $int ) { 1608 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, $int );1608 $size_array = $this->get_image_size_array_from_meta( $image_meta, $int ); 1609 1609 $image_url = wp_get_attachment_image_url( $id, $int ); 1610 1610 … … 1616 1616 } 1617 1617 1618 $expected_srcset = $this-> _src_first( $_expected, $image_url, $size_array[0] );1618 $expected_srcset = $this->src_first( $_expected, $image_url, $size_array[0] ); 1619 1619 $this->assertSame( $expected_srcset, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); 1620 1620 } … … 1629 1629 * @requires function imagejpeg 1630 1630 */ 1631 function test_wp_calculate_image_srcset_with_edits() {1631 public function test_wp_calculate_image_srcset_with_edits() { 1632 1632 // For this test we're going to mock metadata changes from an edit. 1633 1633 // Start by getting the attachment metadata. 1634 1634 $image_meta = wp_get_attachment_metadata( self::$large_id ); 1635 1635 $image_url = wp_get_attachment_image_url( self::$large_id, 'medium' ); 1636 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, 'medium' );1636 $size_array = $this->get_image_size_array_from_meta( $image_meta, 'medium' ); 1637 1637 1638 1638 // Copy hash generation method used in wp_save_image(). … … 1663 1663 * @requires function imagejpeg 1664 1664 */ 1665 function test_wp_calculate_image_srcset_with_absolute_path_in_meta() {1665 public function test_wp_calculate_image_srcset_with_absolute_path_in_meta() { 1666 1666 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1667 1667 … … 1697 1697 foreach ( $intermediates as $int ) { 1698 1698 $image_url = wp_get_attachment_image_url( self::$large_id, $int ); 1699 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, $int );1699 $size_array = $this->get_image_size_array_from_meta( $image_meta, $int ); 1700 1700 1701 1701 if ( 'full' === $int ) { … … 1706 1706 } 1707 1707 1708 $expected_srcset = $this-> _src_first( $_expected, $image_url, $size_array[0] );1708 $expected_srcset = $this->src_first( $_expected, $image_url, $size_array[0] ); 1709 1709 $this->assertSame( $expected_srcset, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) ); 1710 1710 } … … 1714 1714 * @ticket 33641 1715 1715 */ 1716 function test_wp_calculate_image_srcset_false() {1716 public function test_wp_calculate_image_srcset_false() { 1717 1717 $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() ); 1718 1718 … … 1725 1725 * @requires function imagejpeg 1726 1726 */ 1727 function test_wp_calculate_image_srcset_no_width() {1727 public function test_wp_calculate_image_srcset_no_width() { 1728 1728 $file = get_attached_file( self::$large_id ); 1729 1729 $image_url = wp_get_attachment_image_url( self::$large_id, 'medium' ); … … 1742 1742 * @ticket 33641 1743 1743 */ 1744 function test_wp_calculate_image_srcset_ratio_variance() {1744 public function test_wp_calculate_image_srcset_ratio_variance() { 1745 1745 // Mock data for this test. 1746 1746 $size_array = array( 218, 300 ); … … 1791 1791 * @ticket 33641 1792 1792 */ 1793 function test_wp_calculate_image_srcset_include_src() {1793 public function test_wp_calculate_image_srcset_include_src() { 1794 1794 // Mock data for this test. 1795 1795 $size_array = array( 2000, 1000 ); … … 1840 1840 * @ticket 35480 1841 1841 */ 1842 function test_wp_calculate_image_srcset_corrupted_image_meta() {1842 public function test_wp_calculate_image_srcset_corrupted_image_meta() { 1843 1843 $size_array = array( 300, 150 ); 1844 1844 $image_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-300x150.png'; … … 1914 1914 * @ticket 33641 1915 1915 */ 1916 function test_wp_calculate_image_srcset_with_spaces_in_filenames() {1916 public function test_wp_calculate_image_srcset_with_spaces_in_filenames() { 1917 1917 // Mock data for this test. 1918 1918 $image_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test image-300x150.png'; … … 1962 1962 * @requires function imagejpeg 1963 1963 */ 1964 function test_wp_get_attachment_image_srcset() {1964 public function test_wp_get_attachment_image_srcset() { 1965 1965 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1966 1966 … … 1993 1993 $expected .= $uploads_dir . $image_meta['file'] . ' ' . $image_meta['width'] . 'w'; 1994 1994 1995 $expected_srcset = $this-> _src_first( $expected, $uploads_dir . $image_meta['file'], $size_array[0] );1995 $expected_srcset = $this->src_first( $expected, $uploads_dir . $image_meta['file'], $size_array[0] ); 1996 1996 1997 1997 $this->assertSame( $expected_srcset, $srcset ); … … 2001 2001 * @ticket 33641 2002 2002 */ 2003 function test_wp_get_attachment_image_srcset_single_srcset() {2003 public function test_wp_get_attachment_image_srcset_single_srcset() { 2004 2004 $image_meta = wp_get_attachment_metadata( self::$large_id ); 2005 2005 $size_array = array( 150, 150 ); … … 2016 2016 * @ticket 33641 2017 2017 */ 2018 function test_wp_get_attachment_image_srcset_invalidsize() {2018 public function test_wp_get_attachment_image_srcset_invalidsize() { 2019 2019 $image_meta = wp_get_attachment_metadata( self::$large_id ); 2020 2020 $invalid_size = 'nailthumb'; … … 2032 2032 * @ticket 33641 2033 2033 */ 2034 function test_wp_get_attachment_image_sizes() {2034 public function test_wp_get_attachment_image_sizes() { 2035 2035 // Test sizes against the default WP sizes. 2036 2036 $intermediates = array( 'thumbnail', 'medium', 'medium_large', 'large' ); … … 2053 2053 * @requires function imagejpeg 2054 2054 */ 2055 function test_wp_calculate_image_sizes() {2055 public function test_wp_calculate_image_sizes() { 2056 2056 // Test sizes against the default WP sizes. 2057 2057 $intermediates = array( 'thumbnail', 'medium', 'medium_large', 'large' ); … … 2062 2062 2063 2063 foreach ( $intermediates as $int_size ) { 2064 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, $int_size );2064 $size_array = $this->get_image_size_array_from_meta( $image_meta, $int_size ); 2065 2065 $image_src = $image_meta['sizes'][ $int_size ]['file']; 2066 2066 list( $width, $height ) = $size_array; … … 2077 2077 * @requires function imagejpeg 2078 2078 */ 2079 function test_wp_filter_content_tags_srcset_sizes() {2079 public function test_wp_filter_content_tags_srcset_sizes() { 2080 2080 $image_meta = wp_get_attachment_metadata( self::$large_id ); 2081 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, 'medium' );2081 $size_array = $this->get_image_size_array_from_meta( $image_meta, 'medium' ); 2082 2082 2083 2083 $srcset = sprintf( 'srcset="%s"', wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta ) ); … … 2167 2167 * @ticket 33641 2168 2168 */ 2169 function test_wp_filter_content_tags_srcset_sizes_wrong() {2169 public function test_wp_filter_content_tags_srcset_sizes_wrong() { 2170 2170 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); 2171 2171 $img = wp_img_tag_add_loading_attr( $img, 'test' ); … … 2180 2180 * @ticket 33641 2181 2181 */ 2182 function test_wp_filter_content_tags_srcset_sizes_with_preexisting_srcset() {2182 public function test_wp_filter_content_tags_srcset_sizes_with_preexisting_srcset() { 2183 2183 // Generate HTML and add a dummy srcset attribute. 2184 2184 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2194 2194 * @ticket 34528 2195 2195 */ 2196 function test_wp_calculate_image_srcset_animated_gifs() {2196 public function test_wp_calculate_image_srcset_animated_gifs() { 2197 2197 // Mock meta for an animated gif. 2198 2198 $image_meta = array( … … 2239 2239 * @requires function imagejpeg 2240 2240 */ 2241 function test_wp_filter_content_tags_schemes() {2241 public function test_wp_filter_content_tags_schemes() { 2242 2242 $image_meta = wp_get_attachment_metadata( self::$large_id ); 2243 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, 'medium' );2243 $size_array = $this->get_image_size_array_from_meta( $image_meta, 'medium' ); 2244 2244 2245 2245 $srcset = sprintf( 'srcset="%s"', wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta ) ); … … 2290 2290 * @ticket 33641 2291 2291 */ 2292 function test_wp_get_attachment_image_with_https_on() {2292 public function test_wp_get_attachment_image_with_https_on() { 2293 2293 // Mock meta for the image. 2294 2294 $image_meta = array( … … 2335 2335 * @ticket 36084 2336 2336 */ 2337 function test_get_image_send_to_editor_defaults() {2337 public function test_get_image_send_to_editor_defaults() { 2338 2338 $id = self::$large_id; 2339 2339 $caption = ''; … … 2355 2355 * @ticket 36084 2356 2356 */ 2357 function test_get_image_send_to_editor_defaults_with_optional_params() {2357 public function test_get_image_send_to_editor_defaults_with_optional_params() { 2358 2358 $id = self::$large_id; 2359 2359 $caption = 'A test caption.'; … … 2379 2379 * @ticket 36084 2380 2380 */ 2381 function test_get_image_send_to_editor_defaults_no_caption_no_rel() {2381 public function test_get_image_send_to_editor_defaults_no_caption_no_rel() { 2382 2382 $id = self::$large_id; 2383 2383 $caption = ''; … … 2411 2411 * @requires function imagejpeg 2412 2412 */ 2413 function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() {2414 add_filter( 'wp_get_attachment_metadata', array( $this, ' _filter_36246' ), 10, 2 );2413 public function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() { 2414 add_filter( 'wp_get_attachment_metadata', array( $this, 'filter_36246' ), 10, 2 ); 2415 2415 2416 2416 remove_all_filters( 'wp_calculate_image_sizes' ); … … 2428 2428 $actual = wp_get_attachment_image( self::$large_id, 'testsize' ); 2429 2429 2430 remove_filter( 'wp_get_attachment_metadata', array( $this, ' _filter_36246' ) );2430 remove_filter( 'wp_get_attachment_metadata', array( $this, 'filter_36246' ) ); 2431 2431 2432 2432 $this->assertSame( $expected, $actual ); 2433 2433 } 2434 2434 2435 function _filter_36246( $data, $attachment_id ) {2435 public function filter_36246( $data, $attachment_id ) { 2436 2436 $data['sizes']['testsize'] = array( 2437 2437 'file' => 'test-image-testsize-999x999.jpg', … … 2446 2446 * @ticket 50679 2447 2447 */ 2448 function test_wp_get_attachment_metadata_should_return_false_if_no_attachment() {2448 public function test_wp_get_attachment_metadata_should_return_false_if_no_attachment() { 2449 2449 $post_id = self::factory()->post->create(); 2450 2450 $data = wp_get_attachment_metadata( $post_id ); … … 2474 2474 * @ticket 35218 2475 2475 */ 2476 function test_wp_get_media_creation_timestamp_video_asf() {2476 public function test_wp_get_media_creation_timestamp_video_asf() { 2477 2477 $metadata = array( 2478 2478 'fileformat' => 'asf', … … 2490 2490 * @ticket 35218 2491 2491 */ 2492 function test_wp_get_media_creation_timestamp_video_matroska() {2492 public function test_wp_get_media_creation_timestamp_video_matroska() { 2493 2493 $metadata = array( 2494 2494 'fileformat' => 'matroska', … … 2508 2508 * @ticket 35218 2509 2509 */ 2510 function test_wp_get_media_creation_timestamp_video_quicktime() {2510 public function test_wp_get_media_creation_timestamp_video_quicktime() { 2511 2511 $metadata = array( 2512 2512 'fileformat' => 'quicktime', … … 2528 2528 * @ticket 35218 2529 2529 */ 2530 function test_wp_get_media_creation_timestamp_video_webm() {2530 public function test_wp_get_media_creation_timestamp_video_webm() { 2531 2531 $metadata = array( 2532 2532 'fileformat' => 'webm', … … 2551 2551 * @ticket 42017 2552 2552 */ 2553 function test_wp_read_audio_metadata_adds_creation_date_with_mp4() {2553 public function test_wp_read_audio_metadata_adds_creation_date_with_mp4() { 2554 2554 $video = DIR_TESTDATA . '/uploads/small-video.mp4'; 2555 2555 $metadata = wp_read_audio_metadata( $video ); … … 2561 2561 * @ticket 35218 2562 2562 */ 2563 function test_wp_read_video_metadata_adds_creation_date_with_quicktime() {2563 public function test_wp_read_video_metadata_adds_creation_date_with_quicktime() { 2564 2564 $video = DIR_TESTDATA . '/uploads/small-video.mov'; 2565 2565 $metadata = wp_read_video_metadata( $video ); … … 2571 2571 * @ticket 35218 2572 2572 */ 2573 function test_wp_read_video_metadata_adds_creation_date_with_mp4() {2573 public function test_wp_read_video_metadata_adds_creation_date_with_mp4() { 2574 2574 $video = DIR_TESTDATA . '/uploads/small-video.mp4'; 2575 2575 $metadata = wp_read_video_metadata( $video ); … … 2581 2581 * @ticket 35218 2582 2582 */ 2583 function test_wp_read_video_metadata_adds_creation_date_with_mkv() {2583 public function test_wp_read_video_metadata_adds_creation_date_with_mkv() { 2584 2584 $video = DIR_TESTDATA . '/uploads/small-video.mkv'; 2585 2585 $metadata = wp_read_video_metadata( $video ); … … 2591 2591 * @ticket 35218 2592 2592 */ 2593 function test_wp_read_video_metadata_adds_creation_date_with_webm() {2593 public function test_wp_read_video_metadata_adds_creation_date_with_webm() { 2594 2594 $video = DIR_TESTDATA . '/uploads/small-video.webm'; 2595 2595 $metadata = wp_read_video_metadata( $video ); … … 2700 2700 * @requires function imagejpeg 2701 2701 */ 2702 function test_wp_filter_content_tags_width_height() {2702 public function test_wp_filter_content_tags_width_height() { 2703 2703 $image_meta = wp_get_attachment_metadata( self::$large_id ); 2704 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, 'medium' );2704 $size_array = $this->get_image_size_array_from_meta( $image_meta, 'medium' ); 2705 2705 2706 2706 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2747 2747 * @requires function imagejpeg 2748 2748 */ 2749 function test_wp_filter_content_tags_loading_lazy() {2749 public function test_wp_filter_content_tags_loading_lazy() { 2750 2750 $image_meta = wp_get_attachment_metadata( self::$large_id ); 2751 $size_array = $this-> _get_image_size_array_from_meta( $image_meta, 'medium' );2751 $size_array = $this->get_image_size_array_from_meta( $image_meta, 'medium' ); 2752 2752 2753 2753 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); … … 2803 2803 * @ticket 50756 2804 2804 */ 2805 function test_wp_filter_content_tags_loading_lazy_opted_in() {2805 public function test_wp_filter_content_tags_loading_lazy_opted_in() { 2806 2806 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); 2807 2807 $lazy_img = wp_img_tag_add_loading_attr( $img, 'test' ); … … 2833 2833 * @ticket 50756 2834 2834 */ 2835 function test_wp_filter_content_tags_loading_lazy_opted_out() {2835 public function test_wp_filter_content_tags_loading_lazy_opted_out() { 2836 2836 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); 2837 2837 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; … … 2859 2859 * @ticket 50367 2860 2860 */ 2861 function test_wp_img_tag_add_loading_attr() {2861 public function test_wp_img_tag_add_loading_attr() { 2862 2862 $img = '<img src="example.png" alt=" width="300" height="225" />'; 2863 2863 $img = wp_img_tag_add_loading_attr( $img, 'test' ); … … 2870 2870 * @ticket 50367 2871 2871 */ 2872 function test_wp_img_tag_add_loading_attr_without_src() {2872 public function test_wp_img_tag_add_loading_attr_without_src() { 2873 2873 $img = '<img alt=" width="300" height="225" />'; 2874 2874 $img = wp_img_tag_add_loading_attr( $img, 'test' ); … … 2881 2881 * @ticket 50367 2882 2882 */ 2883 function test_wp_img_tag_add_loading_attr_with_single_quotes() {2883 public function test_wp_img_tag_add_loading_attr_with_single_quotes() { 2884 2884 $img = "<img src='example.png' alt=' width='300' height='225' />"; 2885 2885 $img = wp_img_tag_add_loading_attr( $img, 'test' ); … … 2896 2896 * @ticket 50425 2897 2897 */ 2898 function test_wp_img_tag_add_loading_attr_opt_out() {2898 public function test_wp_img_tag_add_loading_attr_opt_out() { 2899 2899 $img = '<img src="example.png" alt=" width="300" height="225" />'; 2900 2900 add_filter( 'wp_img_tag_add_loading_attr', '__return_false' ); … … 2906 2906 * @ticket 50756 2907 2907 */ 2908 function test_wp_iframe_tag_add_loading_attr() {2908 public function test_wp_iframe_tag_add_loading_attr() { 2909 2909 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 2910 2910 $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); … … 2916 2916 * @ticket 50756 2917 2917 */ 2918 function test_wp_iframe_tag_add_loading_attr_without_src() {2918 public function test_wp_iframe_tag_add_loading_attr_without_src() { 2919 2919 $iframe = '<iframe width="640" height="360"></iframe>'; 2920 2920 $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); … … 2926 2926 * @ticket 50756 2927 2927 */ 2928 function test_wp_iframe_tag_add_loading_attr_with_single_quotes() {2928 public function test_wp_iframe_tag_add_loading_attr_with_single_quotes() { 2929 2929 $iframe = "<iframe src='https://www.example.com' width='640' height='360'></iframe>"; 2930 2930 $iframe = wp_iframe_tag_add_loading_attr( $iframe, 'test' ); … … 2940 2940 * @ticket 50756 2941 2941 */ 2942 function test_wp_iframe_tag_add_loading_attr_opt_out() {2942 public function test_wp_iframe_tag_add_loading_attr_opt_out() { 2943 2943 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 2944 2944 add_filter( 'wp_iframe_tag_add_loading_attr', '__return_false' ); … … 2951 2951 * @ticket 52768 2952 2952 */ 2953 function test_wp_iframe_tag_add_loading_attr_skip_wp_embed() {2953 public function test_wp_iframe_tag_add_loading_attr_skip_wp_embed() { 2954 2954 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 2955 2955 $fallback = '<blockquote>Fallback content.</blockquote>'; … … 2964 2964 * @ticket 50425 2965 2965 */ 2966 function test_wp_get_attachment_image_loading() {2966 public function test_wp_get_attachment_image_loading() { 2967 2967 $img = wp_get_attachment_image( self::$large_id ); 2968 2968 … … 2974 2974 * @ticket 50425 2975 2975 */ 2976 function test_wp_get_attachment_image_loading_opt_out() {2976 public function test_wp_get_attachment_image_loading_opt_out() { 2977 2977 add_filter( 'wp_lazy_loading_enabled', '__return_false' ); 2978 2978 $img = wp_get_attachment_image( self::$large_id ); … … 2986 2986 * @ticket 50425 2987 2987 */ 2988 function test_wp_get_attachment_image_loading_opt_out_individual() {2988 public function test_wp_get_attachment_image_loading_opt_out_individual() { 2989 2989 // The default is already tested above, the filter below ensures that 2990 2990 // lazy-loading is definitely enabled globally for images. … … 3006 3006 * @param bool $expected Expected return value. 3007 3007 */ 3008 function test_wp_lazy_loading_enabled_tag_name_defaults( $tag_name, $expected ) {3008 public function test_wp_lazy_loading_enabled_tag_name_defaults( $tag_name, $expected ) { 3009 3009 if ( $expected ) { 3010 3010 $this->assertTrue( wp_lazy_loading_enabled( $tag_name, 'the_content' ) ); … … 3014 3014 } 3015 3015 3016 function data_wp_lazy_loading_enabled_tag_name_defaults() {3016 public function data_wp_lazy_loading_enabled_tag_name_defaults() { 3017 3017 return array( 3018 3018 'img => true' => array( 'img', true ), … … 3030 3030 * @param bool $expected Expected return value. 3031 3031 */ 3032 function test_wp_lazy_loading_enabled_context_defaults( $context, $expected ) {3032 public function test_wp_lazy_loading_enabled_context_defaults( $context, $expected ) { 3033 3033 if ( $expected ) { 3034 3034 $this->assertTrue( wp_lazy_loading_enabled( 'img', $context ) ); … … 3038 3038 } 3039 3039 3040 function data_wp_lazy_loading_enabled_context_defaults() {3040 public function data_wp_lazy_loading_enabled_context_defaults() { 3041 3041 return array( 3042 3042 'wp_get_attachment_image => true' => array( 'wp_get_attachment_image', true ), … … 3053 3053 * @ticket 50543 3054 3054 */ 3055 function test_wp_image_file_matches_image_meta() {3055 public function test_wp_image_file_matches_image_meta() { 3056 3056 $image_meta = wp_get_attachment_metadata( self::$large_id ); 3057 3057 $image_src_full = wp_get_attachment_image_url( self::$large_id, 'full' ); … … 3065 3065 * @ticket 50543 3066 3066 */ 3067 function test_wp_image_file_matches_image_meta_no_subsizes() {3067 public function test_wp_image_file_matches_image_meta_no_subsizes() { 3068 3068 $image_meta = wp_get_attachment_metadata( self::$large_id ); 3069 3069 $image_src = wp_get_attachment_image_url( self::$large_id, 'full' ); … … 3077 3077 * @ticket 50543 3078 3078 */ 3079 function test_wp_image_file_matches_image_meta_invalid_meta() {3079 public function test_wp_image_file_matches_image_meta_invalid_meta() { 3080 3080 $image_meta = ''; // Attachment is not an image. 3081 3081 $image_src = $this->img_url; … … 3087 3087 * @ticket 50543 3088 3088 */ 3089 function test_wp_image_file_matches_image_meta_different_meta() {3089 public function test_wp_image_file_matches_image_meta_different_meta() { 3090 3090 $image_meta = wp_get_attachment_metadata( self::$large_id ); 3091 3091 $image_src = $this->img_url; // Different image. … … 3097 3097 * @ticket 50543 3098 3098 */ 3099 function test_wp_image_file_matches_image_meta_original_image() {3099 public function test_wp_image_file_matches_image_meta_original_image() { 3100 3100 $image_meta = wp_get_attachment_metadata( self::$large_id ); 3101 3101 $image_src = wp_get_original_image_url( self::$large_id ); … … 3107 3107 * @ticket 22101 3108 3108 */ 3109 function test_gallery_shortcode_when_is_feed_true() {3109 public function test_gallery_shortcode_when_is_feed_true() { 3110 3110 3111 3111 $this->go_to( '/?feed=rss2' ); … … 3149 3149 * 3150 3150 */ 3151 function test_attachment_permalinks_based_on_parent_status( $post_key, $expected_url, $expected_404 ) {3151 public function test_attachment_permalinks_based_on_parent_status( $post_key, $expected_url, $expected_404 ) { 3152 3152 $this->set_permalink_structure( '/%postname%' ); 3153 3153 $post = get_post( self::$post_ids[ $post_key ] ); … … 3178 3178 * } 3179 3179 */ 3180 function data_attachment_permalinks_based_on_parent_status() {3180 public function data_attachment_permalinks_based_on_parent_status() { 3181 3181 return array( 3182 3182 array( 'draft-attachment', '/?attachment_id=%ID%', true ),
Note: See TracChangeset
for help on using the changeset viewer.