WordPress.org

Make WordPress Core

Ticket #34196: working_bad_tests.diff

File working_bad_tests.diff, 14.5 KB (added by mikeschroder, 4 years ago)

Initial medium-large patch. No UI. Unit Tests Need Fixing.

  • src/wp-admin/includes/schema.php

     
    506506        // 4.3.0
    507507        'finished_splitting_shared_terms' => 1,
    508508        'site_icon' => 0,
     509
     510        // 4.4.0
     511        'medium_large_size_w' => 768,
     512        'medium_large_size_h' => 0,
    509513        );
    510514
    511515        // 3.3
  • src/wp-admin/options.php

     
    8484$whitelist_options = array(
    8585        'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'timezone_string', 'WPLANG' ),
    8686        'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
    87         'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
     87        'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'medium_large_size_w', 'medium_large_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
    8888        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
    8989        'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' )
    9090);
  • src/wp-includes/class-wp-image-editor-gd.php

     
    212212         * @access public
    213213         *
    214214         * @param array $sizes {
    215          *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
     215         *     An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
    216216         *
    217217         *     Either a height or width must be provided.
    218218         *     If one of the two is set to null, the resize will
  • src/wp-includes/class-wp-image-editor-imagick.php

     
    270270         * @access public
    271271         *
    272272         * @param array $sizes {
    273          *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
     273         *     An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
    274274         *
    275275         *     Either a height or width must be provided.
    276276         *     If one of the two is set to null, the resize will
  • src/wp-includes/class-wp-xmlrpc-server.php

     
    513513                                'readonly'      => false,
    514514                                'option'        => 'medium_size_h'
    515515                        ),
     516                        'medium_large_size_w'   => array(
     517                                'desc'          => __( 'Medium-Large size image width' ),
     518                                'readonly'      => false,
     519                                'option'        => 'medium_large_size_w'
     520                        ),
     521                        'medium_large_size_h'   => array(
     522                                'desc'          => __( 'Medium-Large size image height' ),
     523                                'readonly'      => false,
     524                                'option'        => 'medium_large_size_h'
     525                        ),
    516526                        'large_size_w'      => array(
    517527                                'desc'          => __( 'Large size image width' ),
    518528                                'readonly'      => false,
  • src/wp-includes/formatting.php

     
    36623662                case 'thumbnail_size_h':
    36633663                case 'medium_size_w':
    36643664                case 'medium_size_h':
     3665                case 'medium_large_size_w':
     3666                case 'medium_large_size_h':
    36653667                case 'large_size_w':
    36663668                case 'large_size_h':
    36673669                case 'mailserver_port':
  • src/wp-includes/media.php

     
    1414 * The `$size` parameter accepts either an array or a string. The supported string
    1515 * values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
    1616 * 128 width and 96 height in pixels. Also supported for the string value is
    17  * 'medium' and 'full'. The 'full' isn't actually supported, but any value other
     17 * 'medium_large', 'medium' and 'full'. The 'full' isn't actually supported, but any value other
    1818 * than the supported will result in the content_width size or 500 if that is
    1919 * not set.
    2020 *
     
    6060        elseif ( $size == 'medium' ) {
    6161                $max_width = intval(get_option('medium_size_w'));
    6262                $max_height = intval(get_option('medium_size_h'));
     63
    6364                // if no width is set, default to the theme content width if available
    6465        }
     66        elseif ( $size == 'medium_large' ) {
     67                /*
     68                 * We're inserting an Evan-sized image into the editor. If it's a really
     69                 * big image we'll scale it down to fit reasonably within the editor
     70                 * itself, and within the theme's content width if it's known. The user
     71                 * can resize it in the editor if they wish.
     72                 */
     73                $max_width = intval(get_option('medium_large_size_w'));
     74                $max_height = intval(get_option('medium_large_size_h'));
     75
     76                if ( intval($content_width) > 0 ) {
     77                        $max_width = min( intval($content_width), $max_width );
     78                }
     79        }
    6580        elseif ( $size == 'large' ) {
    6681                /*
    6782                 * We're inserting a large size image into the editor. If it's a really
     
    7186                 */
    7287                $max_width = intval(get_option('large_size_w'));
    7388                $max_height = intval(get_option('large_size_h'));
    74                 if ( intval($content_width) > 0 )
     89                if ( intval($content_width) > 0 ) {
    7590                        $max_width = min( intval($content_width), $max_width );
     91                }
    7692        } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {
    7793                $max_width = intval( $_wp_additional_image_sizes[$size]['width'] );
    7894                $max_height = intval( $_wp_additional_image_sizes[$size]['height'] );
     
    706722 */
    707723function get_intermediate_image_sizes() {
    708724        global $_wp_additional_image_sizes;
    709         $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
     725        $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes
    710726        if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
    711727                $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
    712728
     
    716732         * @since 2.5.0
    717733         *
    718734         * @param array $image_sizes An array of intermediate image sizes. Defaults
    719          *                           are 'thumbnail', 'medium', 'large'.
     735         *                           are 'thumbnail', 'medium', 'medium_large', 'large'.
    720736         */
    721737        return apply_filters( 'intermediate_image_sizes', $image_sizes );
    722738}
  • tests/phpunit/tests/media.php

     
    728728                                'descriptor' => 'w',
    729729                                'value'      => $image['sizes']['medium']['width'],
    730730                        ),
     731                        array(
     732                                'url'        => 'http://example.org/wp-content/uploads/' . $year_month . '/' . $image['sizes']['medium_large']['file'],
     733                                'descriptor' => 'w',
     734                                'value'      => $image['sizes']['medium_large']['width'],
     735                        ),
    731736                        array(
    732737                                'url'        => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month . '/' . $image['sizes']['large']['file'],
    733738                                'descriptor' => 'w',
     
    771776                                'value'      => $image['sizes']['medium']['width'],
    772777                        ),
    773778                        array(
     779                                'url'        => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image['sizes']['medium_large']['file'],
     780                                'descriptor' => 'w',
     781                                'value'      => $image['sizes']['medium_large']['width'],
     782                        ),
     783                        array(
    774784                                'url'        => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image['sizes']['large']['file'],
    775785                                'descriptor' => 'w',
    776786                                'value'      => $image['sizes']['large']['width'],
     
    783793                );
    784794
    785795                // Set up test cases for all expected size names and a random one.
    786                 $sizes = array( 'medium', 'large', 'full', 'yoav' );
     796                $sizes = array( 'medium', 'large', 'medium_large', 'full', 'yoav' );
    787797
    788798                foreach ( $sizes as $size ) {
    789799                        $this->assertSame( $expected, wp_get_attachment_image_srcset_array( $id, $size ) );
     
    875885                $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    876886                        . $image['sizes']['medium']['file'] . ' ' . $image['sizes']['medium']['width'] . 'w, ';
    877887                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
     888                        . $image['sizes']['medium_large']['file'] . ' ' . $image['sizes']['medium_large']['width'] . 'w, ';
     889                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    878890                        . $image['sizes']['large']['file'] . ' ' . $image['sizes']['large']['width'] . 'w, ';
    879891                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image['file'] . ' ' . $image['width'] .'w';
    880892
     
    899911         */
    900912        function test_wp_get_attachment_image_sizes() {
    901913                // Test sizes against the default WP sizes.
    902                 $intermediates = array('thumbnail', 'medium', 'large');
     914                $intermediates = array('thumbnail', 'medium', 'medium_large', 'large');
    903915
    904916                foreach( $intermediates as $int ) {
    905917                        $width = get_option( $int . '_size_w' );
  • tests/phpunit/tests/post/attachments.php

     
    3535                // intermediate copies should not exist
    3636                $this->assertFalse( image_get_intermediate_size($id, 'thumbnail') );
    3737                $this->assertFalse( image_get_intermediate_size($id, 'medium') );
     38                $this->assertFalse( image_get_intermediate_size($id, 'medium_large') );
    3839
    39                 // medium and full size will both point to the original
     40                // medium, medium_large, and full size will both point to the original
    4041                $downsize = image_downsize($id, 'medium');
    4142                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
    4243                $this->assertEquals( 50, $downsize[1] );
    4344                $this->assertEquals( 50, $downsize[2] );
    4445
     46                $downsize = image_downsize($id, 'medium_large');
     47                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
     48                $this->assertEquals( 50, $downsize[1] );
     49                $this->assertEquals( 50, $downsize[2] );
     50
    4551                $downsize = image_downsize($id, 'full');
    4652                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
    4753                $this->assertEquals( 50, $downsize[1] );
     
    7278                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $thumb['path']) );
    7379
    7480                $this->assertFalse( image_get_intermediate_size($id, 'medium') );
     81                $this->assertFalse( image_get_intermediate_size($id, 'medium_large') );
    7582
    7683                // the thumb url should point to the thumbnail intermediate
    7784                $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
     
    8289                $this->assertEquals( 150, $downsize[1] );
    8390                $this->assertEquals( 150, $downsize[2] );
    8491
    85                 // medium and full will both point to the original
     92                // medium, medium_large, and full will both point to the original
    8693                $downsize = image_downsize($id, 'medium');
    8794                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
    8895                $this->assertEquals( 400, $downsize[1] );
    8996                $this->assertEquals( 300, $downsize[2] );
    9097
     98                $downsize = image_downsize($id, 'medium_large');
     99                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
     100                $this->assertEquals( 400, $downsize[1] );
     101                $this->assertEquals( 300, $downsize[2] );
     102
    91103                $downsize = image_downsize($id, 'full');
    92104                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
    93105                $this->assertEquals( 400, $downsize[1] );
     
    95107
    96108        }
    97109
    98         function test_insert_image_medium() {
     110        function test_insert_image_medium_sizes() {
    99111                if ( !function_exists( 'imagejpeg' ) )
    100112                        $this->markTestSkipped( 'jpeg support unavailable' );
    101113
     
    120132                $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] );
    121133                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path']) );
    122134
     135                $medium_large = image_get_intermediate_size($id, 'medium_large');
     136                $this->assertEquals( '2007-06-17DSC_4173-768x510.jpg', $medium_large['file'] );
     137                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path']) );
     138
    123139                // the thumb url should point to the thumbnail intermediate
    124140                $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
    125141
     
    134150                $this->assertEquals( 400, $downsize[1] );
    135151                $this->assertEquals( 602, $downsize[2] );
    136152
     153                $downsize = image_downsize($id, 'medium_large');
     154                $this->assertEquals( '2007-06-17DSC_4173-768x510.jpg', basename($downsize[0]) );
     155                $this->assertEquals( 510, $downsize[1] );
     156                $this->assertEquals( 768, $downsize[2] );
     157
    137158                $downsize = image_downsize($id, 'full');
    138159                $this->assertEquals( '2007-06-17DSC_4173.jpg', basename($downsize[0]) );
    139160                $this->assertEquals( 680, $downsize[1] );
     
    166187                $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] );
    167188                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path']) );
    168189
     190                $medium_large = image_get_intermediate_size($id, 'medium_large');
     191                $this->assertEquals( '2007-06-17DSC_4173-510x768.jpg', $medium_large['file'] );
     192                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path']) );
     193
    169194                $meta = wp_get_attachment_metadata($id);
    170195                $original = $meta['file'];
    171196                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $original) );
     
    175200
    176201                $this->assertFalse( is_file($thumb['path']) );
    177202                $this->assertFalse( is_file($medium['path']) );
     203                $this->assertFalse( is_file($medium_large['path']) );
    178204                $this->assertFalse( is_file($original) );
    179205        }
    180206