Make WordPress Core

Changeset 52314


Ignore:
Timestamp:
12/03/2021 04:57:19 PM (3 years ago)
Author:
hellofromTonya
Message:

Editor: Enable incomplete unit tests in Tests_Block_Template_Utils:: test_get_block_template_from_file().

At the time tests were backported from Gutenberg, a block template theme was not available in the test suite; thus, the test was marked as markTestIncomplete().

Now that block-theme and block-theme-child test fixture block template themes are available, this commit removes the markTestIncomplete() and adjusts the test to run by switching to the block-theme test fixture.

Follow-up to [51003], [52062], [52247].

Props bernhard-reiter.
Fixes #54551.

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-template-utils.php

    r52286 r52314  
    1414    private static $post;
    1515    private static $template_part_post;
     16    private static $test_theme = 'block-theme';
    1617
    1718    public static function wpSetUpBeforeClass() {
    18         // We may need a block theme.
    19         // switch_theme( 'tt1-blocks' );
    20 
    2119        // Set up a template post corresponding to a different theme.
    2220        // We do this to ensure resolution and slug creation works as expected,
     
    4644            'tax_input'    => array(
    4745                'wp_theme' => array(
    48                     get_stylesheet(),
     46                    self::$test_theme,
    4947                ),
    5048            ),
    5149        );
    5250        self::$post = self::factory()->post->create_and_get( $args );
    53         wp_set_post_terms( self::$post->ID, get_stylesheet(), 'wp_theme' );
     51        wp_set_post_terms( self::$post->ID, self::$test_theme, 'wp_theme' );
    5452
    5553        // Set up template part post.
     
    6260            'tax_input'    => array(
    6361                'wp_theme'              => array(
    64                     get_stylesheet(),
     62                    self::$test_theme,
    6563                ),
    6664                'wp_template_part_area' => array(
     
    7169        self::$template_part_post = self::factory()->post->create_and_get( $template_part_args );
    7270        wp_set_post_terms( self::$template_part_post->ID, WP_TEMPLATE_PART_AREA_HEADER, 'wp_template_part_area' );
    73         wp_set_post_terms( self::$template_part_post->ID, get_stylesheet(), 'wp_theme' );
     71        wp_set_post_terms( self::$template_part_post->ID, self::$test_theme, 'wp_theme' );
     72    }
     73
     74    public function set_up() {
     75        parent::set_up();
     76        switch_theme( self::$test_theme );
    7477    }
    7578
     
    226229     */
    227230    function test_get_block_template_from_file() {
    228         $this->markTestIncomplete();
    229         // Requires switching to a block theme.
    230         /* $id       = get_stylesheet() . '//' . 'index';
     231        $id       = get_stylesheet() . '//' . 'index';
    231232        $template = get_block_template( $id, 'wp_template' );
    232233        $this->assertSame( $id, $template->id );
     
    238239
    239240        // Test template parts.
    240         $id       = get_stylesheet() . '//' . 'header';
     241        $id       = get_stylesheet() . '//' . 'small-header';
    241242        $template = get_block_template( $id, 'wp_template_part' );
    242243        $this->assertSame( $id, $template->id );
    243244        $this->assertSame( get_stylesheet(), $template->theme );
    244         $this->assertSame( 'header', $template->slug );
     245        $this->assertSame( 'small-header', $template->slug );
    245246        $this->assertSame( 'publish', $template->status );
    246247        $this->assertSame( 'theme', $template->source );
    247248        $this->assertSame( 'wp_template_part', $template->type );
    248249        $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template->area );
    249         */
    250250    }
    251251
Note: See TracChangeset for help on using the changeset viewer.