Changeset 47122 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/media.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r47010 r47122 273 273 return array( 274 274 275 // Should embed 275 // Should embed. 276 276 array( 277 277 'https://w.org', … … 309 309 ), 310 310 311 // Should NOT embed 311 // Should NOT embed. 312 312 array( 313 313 'test https://w.org</p>', … … 337 337 338 338 function test_wp_prepare_attachment_for_js() { 339 // Attachment without media 339 // Attachment without media. 340 340 $id = wp_insert_attachment( 341 341 array( … … 354 354 $this->assertEquals( '', $prepped['type'] ); 355 355 $this->assertEquals( '', $prepped['subtype'] ); 356 // #21963, there will be a guid always, so there will be a URL356 // #21963, there will be a GUID always, so there will be a URL. 357 357 $this->assertNotEquals( '', $prepped['url'] ); 358 358 $this->assertEquals( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] ); 359 359 360 // Fake a mime 360 // Fake a mime. 361 361 $post->post_mime_type = 'image/jpeg'; 362 362 $prepped = wp_prepare_attachment_for_js( $post ); … … 365 365 $this->assertEquals( 'jpeg', $prepped['subtype'] ); 366 366 367 // Fake a mime without a slash. See #WP22532 367 // Fake a mime without a slash. See #WP22532. 368 368 $post->post_mime_type = 'image'; 369 369 $prepped = wp_prepare_attachment_for_js( $post ); … … 427 427 $tb = $gb * 1024; 428 428 429 // test if boundaries are correct429 // Test if boundaries are correct. 430 430 $this->assertEquals( '1TB', wp_convert_bytes_to_hr( $tb ) ); 431 431 $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) ); … … 438 438 $this->assertEquals( '1 KB', size_format( $kb ) ); 439 439 440 // now some values around440 // Now some values around. 441 441 $hr = wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb ); 442 442 $this->assertEquals( 1.50000095367, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 ); … … 451 451 $this->assertEquals( 1022.99902344, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 ); 452 452 453 // edge453 // Edge. 454 454 $this->assertEquals( '-1B', wp_convert_bytes_to_hr( -1 ) ); 455 455 $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) ); … … 613 613 $galleries = get_post_galleries( $post_id_two, false ); 614 614 615 // Set the global $post context 615 // Set the global $post context. 616 616 $GLOBALS['post'] = get_post( $post_id_two ); 617 617 $galleries_with_global_context = get_post_galleries( $post_id_two, false ); 618 618 619 // Check that the global post state doesn't affect the results 619 // Check that the global post state doesn't affect the results. 620 620 $this->assertSame( $galleries, $galleries_with_global_context ); 621 621 … … 1012 1012 $sizes = wp_get_additional_image_sizes(); 1013 1013 1014 // Clean up 1014 // Clean up. 1015 1015 remove_image_size( 'test-size' ); 1016 1016 … … 1037 1037 $this->assertTrue( has_image_size( 'test-size' ) ); 1038 1038 1039 // Clean up 1039 // Clean up. 1040 1040 remove_image_size( 'test-size' ); 1041 1041 } … … 1142 1142 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; 1143 1143 1144 // Make a copy of this file as it gets moved during the file upload 1144 // Make a copy of this file as it gets moved during the file upload. 1145 1145 $tmp_name = wp_tempnam( $iptc_file ); 1146 1146 … … 1181 1181 $test_file = DIR_TESTDATA . '/images/test-image.jpg'; 1182 1182 1183 // Make a copy of this file as it gets moved during the file upload 1183 // Make a copy of this file as it gets moved during the file upload. 1184 1184 $tmp_name = wp_tempnam( $test_file ); 1185 1185 … … 1497 1497 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1498 1498 1499 // Disable date organized uploads 1499 // Disable date organized uploads. 1500 1500 add_filter( 'upload_dir', '_upload_dir_no_subdir' ); 1501 1501 … … 1535 1535 } 1536 1536 1537 // Remove the attachment 1537 // Remove the attachment. 1538 1538 wp_delete_attachment( $id ); 1539 1539 remove_filter( 'upload_dir', '_upload_dir_no_subdir' ); … … 1555 1555 $filename_base = wp_basename( $image_meta['file'], '.png' ); 1556 1556 1557 // Add the hash to the image URL 1557 // Add the hash to the image URL. 1558 1558 $image_url = str_replace( $filename_base, $filename_base . '-' . $hash, $image_url ); 1559 1559 … … 1605 1605 $expected .= $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w'; 1606 1606 1607 // Prepend an absolute path to simulate a pre-2.7 upload 1607 // Prepend an absolute path to simulate a pre-2.7 upload. 1608 1608 $image_meta['file'] = 'H:\home\wordpress\trunk/wp-content/uploads/' . $image_meta['file']; 1609 1609 … … 1622 1622 $sizes = wp_calculate_image_srcset( array( 400, 300 ), 'file.png', array() ); 1623 1623 1624 // For canola.jpg we should return 1624 // For canola.jpg we should return. 1625 1625 $this->assertFalse( $sizes ); 1626 1626 } … … 1777 1777 ); 1778 1778 1779 // No sizes array 1779 // No sizes array. 1780 1780 $image_meta1 = $image_meta; 1781 1781 unset( $image_meta1['sizes'] ); … … 1787 1787 $this->assertFalse( wp_calculate_image_srcset( $size_array, $image_src, $image_meta2 ) ); 1788 1788 1789 // File name is incorrect 1789 // File name is incorrect. 1790 1790 $image_meta3 = $image_meta; 1791 1791 $image_meta3['file'] = '/'; 1792 1792 $this->assertFalse( wp_calculate_image_srcset( $size_array, $image_src, $image_meta3 ) ); 1793 1793 1794 // File name is incorrect 1794 // File name is incorrect. 1795 1795 $image_meta4 = $image_meta; 1796 1796 unset( $image_meta4['file'] ); … … 1856 1856 1857 1857 $image_meta = wp_get_attachment_metadata( self::$large_id ); 1858 $size_array = array( 1600, 1200 ); // full size1858 $size_array = array( 1600, 1200 ); // Full size. 1859 1859 1860 1860 $srcset = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta ); … … 1982 1982 $img_html5 = str_replace( ' />', '>', $img ); 1983 1983 1984 // Manually add srcset and sizes to the markup from get_image_tag() ;1984 // Manually add srcset and sizes to the markup from get_image_tag(). 1985 1985 $respimg = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img ); 1986 1986 $respimg_no_size_in_class = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_no_size_in_class ); … … 2032 2032 $image = get_image_tag( self::$large_id, '', '', '', 'medium' ); 2033 2033 2034 // Replace the src URL 2034 // Replace the src URL. 2035 2035 $image_wrong_src = preg_replace( '|src="[^"]+"|', 'src="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/foo.jpg"', $image ); 2036 2036 … … 2433 2433 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; 2434 2434 2435 // Make a copy of this file as it gets moved during the file upload 2435 // Make a copy of this file as it gets moved during the file upload. 2436 2436 $tmp_name = wp_tempnam( $iptc_file ); 2437 2437 … … 2479 2479 $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg'; 2480 2480 2481 // Make a copy of this file as it gets moved during the file upload 2481 // Make a copy of this file as it gets moved during the file upload. 2482 2482 $tmp_name = wp_tempnam( $iptc_file ); 2483 2483
Note: See TracChangeset
for help on using the changeset viewer.