WordPress.org

Make WordPress Core

Changeset 38302


Ignore:
Timestamp:
08/22/2016 04:16:29 AM (4 years ago)
Author:
wonderboymusic
Message:

Media: fix unit test after [38296].

https://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages

Fixes #36246.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r38296 r38302  
    77class Tests_Media extends WP_UnitTestCase {
    88    protected static $large_id;
     9    protected static $_sizes;
    910
    1011    public static function wpSetUpBeforeClass( $factory ) {
     12        self::$_sizes = $GLOBALS['_wp_additional_image_sizes'];
     13        $GLOBALS['_wp_additional_image_sizes'] = array();
     14
    1115        $filename = DIR_TESTDATA . '/images/test-image-large.png';
    1216        self::$large_id = $factory->attachment->create_upload_object( $filename );
     
    1519    public static function wpTearDownAfterClass() {
    1620        wp_delete_attachment( self::$large_id );
     21
     22        $GLOBALS['_wp_additional_image_sizes'] = self::$_sizes;
    1723    }
    1824
     
    17711777        add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 );
    17721778
     1779        remove_all_filters( 'wp_calculate_image_sizes' );
     1780
    17731781        $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" />';
     1782        $year = date( 'Y' );
     1783        $month = date( 'm' );
     1784
     1785        $expected = '<img width="999" height="999" src="http://example.org/wp-content/uploads/' . $year . '/' . $month . '/test-image-testsize-999x999.png"' .
     1786            ' class="attachment-testsize size-testsize" alt="test-image-large.png"' .
     1787            ' srcset="http://example.org/wp-content/uploads/' . $year . '/' . $month . '/test-image-testsize-999x999.png 999w,' .
     1788                ' http://example.org/wp-content/uploads/' . $year . '/' . $month . '/test-image-large-150x150.png 150w"' .
     1789                ' sizes="(max-width: 999px) 100vw, 999px" />';
    17751790
    17761791        remove_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ) );
Note: See TracChangeset for help on using the changeset viewer.