Make WordPress Core


Ignore:
Timestamp:
11/07/2015 01:32:41 AM (9 years ago)
Author:
azaozz
Message:

Responsive images: add test for invalid size name. Remove invalid size from other tests.

Props jaspermdegroot.
See #33641.

File:
1 edited

Legend:

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

    r35524 r35560  
    749749                $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w';
    750750
    751         // Set up test cases for all expected size names and a random one.
    752         $sizes = array( 'medium', 'medium_large', 'large', 'full', 'yoav' );
     751        // Set up test cases for all expected size names.
     752        $sizes = array( 'medium', 'medium_large', 'large', 'full' );
    753753
    754754        foreach ( $sizes as $size ) {
     
    781781                $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w';
    782782
    783         // Set up test cases for all expected size names and a random one.
    784         $sizes = array( 'medium', 'medium_large', 'large', 'full', 'yoav' );
     783        // Set up test cases for all expected size names.
     784        $sizes = array( 'medium', 'medium_large', 'large', 'full' );
    785785
    786786        foreach ( $sizes as $size ) {
     
    863863        $size_array = array( 1600, 1200 ); // full size
    864864
    865         $sizes = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta );
     865        $srcset = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta );
    866866
    867867        $year_month = date('Y/m');
     
    875875        $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file'] . ' ' . $image_meta['width'] .'w';
    876876
    877         $this->assertSame( $expected, $sizes );
     877        $this->assertSame( $expected, $srcset );
    878878    }
    879879
     
    891891
    892892        $this->assertFalse( $sizes );
     893    }
     894
     895    /**
     896     * @ticket 33641
     897     */
     898    function test_wp_get_attachment_image_srcset_invalidsize() {
     899        $image_meta = wp_get_attachment_metadata( self::$large_id );
     900        $invalid_size = 'nailthumb';
     901        $original_size = array( 1600, 1200 );
     902
     903        $srcset = wp_get_attachment_image_srcset( self::$large_id, $invalid_size, $image_meta );
     904
     905        // Expect a srcset for the original full size image to be returned.
     906        $expected = wp_get_attachment_image_srcset( self::$large_id, $original_size, $image_meta );
     907
     908        $this->assertSame( $expected, $srcset );
    893909    }
    894910
Note: See TracChangeset for help on using the changeset viewer.