WordPress.org

Make WordPress Core

Changeset 38838


Ignore:
Timestamp:
10/20/2016 09:06:11 AM (4 years ago)
Author:
pento
Message:

Tests: Fix tests that don't pass when Twenty Seventeen is the default theme.

There are some tests who's outcome can be affected by the default theme, so we need to ensure the Twenty Seventeen functionality is unhooked while the tests are running.

See #38372.

Location:
trunk/tests/phpunit/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/widgets.php

    r37352 r38838  
    4545        remove_action( 'after_setup_theme', 'twentysixteen_setup' );
    4646        remove_action( 'customize_register', 'twentysixteen_customize_register', 11 );
     47        remove_action( 'after_setup_theme', 'twentyseventeen_setup' );
    4748
    4849        $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];
  • trunk/tests/phpunit/tests/media.php

    r38812 r38838  
    3434        $this->img_html = '<img src="' . $this->img_url . '"/>';
    3535        $this->img_meta = array( 'width' => 100, 'height' => 100, 'sizes' => '' );
     36
     37        // Disable Twenty Seventeen changes to the image size attribute
     38        remove_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr' );
     39        remove_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr' );
     40    }
     41
     42    function tearDown() {
     43        parent::tearDown();
     44
     45        // Reset Twenty Seventeen behaviour
     46        add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 );
     47        add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 );
    3648    }
    3749
     
    5668            array( 'width' => 20, 'caption' => $this->caption )
    5769        );
     70
    5871        $this->assertEquals( 2, preg_match_all( '/wp-caption/', $result, $_r ) );
    5972        $this->assertEquals( 1, preg_match_all( '/alignnone/', $result, $_r ) );
    6073        $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );
    61         $this->assertEquals( 1, preg_match_all( "/width: 30/", $result, $_r ) );
     74
     75        if ( current_theme_supports( 'html5', 'caption' ) ) {
     76            $this->assertEquals( 1, preg_match_all( "/width: 20/", $result, $_r ) );
     77        } else {
     78            $this->assertEquals( 1, preg_match_all( "/width: 30/", $result, $_r ) );
     79        }
    6280    }
    6381
Note: See TracChangeset for help on using the changeset viewer.