Changeset 38296 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 08/21/2016 06:14:37 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r38052 r38296 1756 1756 $this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ) ); 1757 1757 } 1758 1759 /** 1760 * Tests if wp_get_attachment_image() uses wp_get_attachment_metadata(). 1761 * 1762 * In this way, the meta data can be filtered using the filter 1763 * `wp_get_attachment_metadata`. 1764 * 1765 * The test checks if the image size that is added in the filter is 1766 * used in the output of `wp_get_attachment_image()`. 1767 * 1768 * @ticket 36246 1769 */ 1770 function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() { 1771 add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 ); 1772 1773 $actual = wp_get_attachment_image( self::$large_id, 'testsize' ); 1774 $expected = '<img width="999" height="999" src="http://example.org/wp-content/uploads/2016/03/test-image-testsize-999x999.png" class="attachment-testsize size-testsize" alt="test-image-large.png" srcset="http://example.org/wp-content/uploads/2016/03/test-image-large-150x150.png 150w, http://example.org/wp-content/uploads/2016/03/test-image-testsize-999x999.png 999w" sizes="(max-width: 999px) 100vw, 999px" />'; 1775 1776 remove_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ) ); 1777 1778 $this->assertSame( $expected, $actual ); 1779 } 1780 1781 function _filter_36246( $data, $attachment_id ) { 1782 $data['sizes']['testsize'] = array( 1783 'file' => 'test-image-testsize-999x999.png', 1784 'width' => 999, 1785 'height' => 999, 1786 'mime-type' => 'image/png', 1787 ); 1788 return $data; 1789 } 1758 1790 } 1759 1791
Note: See TracChangeset
for help on using the changeset viewer.