Make WordPress Core

Ticket #33641: 33641.6.diff

File 33641.6.diff, 2.8 KB (added by jaspermdegroot, 9 years ago)

Changes in media tests

  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 5734f3e..75e7df5 100644
    EOF; 
    748748                                $uploads_dir_url . $year_month . '/' . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ' .
    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 ) {
    755755                        $image_url = wp_get_attachment_image_url( self::$large_id, $size );
    EOF; 
    780780                                $uploads_dir_url . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ' .
    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 ) {
    787787                        $size_array = $this->_get_image_size_array_from_name( $size );
    EOF; 
    862862                $image_meta = wp_get_attachment_metadata( self::$large_id );
    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');
    868868
    EOF; 
    874874                        . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ';
    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
    880880        /**
    EOF; 
    895895        /**
    896896         * @ticket 33641
    897897         */
     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 );
     909        }
     910
     911        /**
     912         * @ticket 33641
     913         */
    898914        function test_wp_get_attachment_image_sizes() {
    899915                // Test sizes against the default WP sizes.
    900916                $intermediates = array('thumbnail', 'medium', 'medium_large', 'large');