Make WordPress Core


Ignore:
Timestamp:
04/07/2022 01:33:03 PM (3 years ago)
Author:
gziolo
Message:

Site Editor: Resolve homepage template on server-side

Backports change from Gutenberg to support server-side home template resolution in the Site Editor. Original PR https://github.com/WordPress/gutenberg/pull/38817.

Props Mamaduka.
See #55505.

File:
1 edited

Legend:

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

    r52697 r53093  
    189189        $this->assertSame( '', $resolved_template_path );
    190190    }
     191
     192    /**
     193     * Covers: https://github.com/WordPress/gutenberg/pull/38817.
     194     *
     195     * @ticket 55505
     196     */
     197    public function test_resolve_home_block_template_default_hierarchy() {
     198        $template = _resolve_home_block_template();
     199
     200        $this->assertSame( 'wp_template', $template['postType'] );
     201        $this->assertSame( get_stylesheet() . '//index', $template['postId'] );
     202    }
     203
     204    /**
     205     * @ticket 55505
     206     */
     207    public function test_resolve_home_block_template_static_homepage() {
     208        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     209        update_option( 'show_on_front', 'page' );
     210        update_option( 'page_on_front', $post_id );
     211
     212        $template = _resolve_home_block_template();
     213
     214        $this->assertSame( 'page', $template['postType'] );
     215        $this->assertSame( $post_id, $template['postId'] );
     216
     217        delete_option( 'show_on_front', 'page' );
     218    }
     219
     220    /**
     221     * @ticket 55505
     222     */
     223    public function test_resolve_home_block_template_no_resolution() {
     224        switch_theme( 'stylesheetonly' );
     225        $template = _resolve_home_block_template();
     226
     227        $this->assertNull( $template );
     228    }
    191229}
Note: See TracChangeset for help on using the changeset viewer.