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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52314 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-12-03 16:57:19 +00:00
parent 281142bfb4
commit 4e6823d17c
2 changed files with 16 additions and 13 deletions

View File

@ -0,0 +1,3 @@
<!-- wp:paragraph -->
<p>Small Header Template Part</p>
<!-- /wp:paragraph -->

View File

@ -13,11 +13,9 @@
class Tests_Block_Template_Utils extends WP_UnitTestCase {
private static $post;
private static $template_part_post;
private static $test_theme = 'block-theme';
public static function wpSetUpBeforeClass() {
// We may need a block theme.
// switch_theme( 'tt1-blocks' );
// Set up a template post corresponding to a different theme.
// We do this to ensure resolution and slug creation works as expected,
// even with another post of that same name present for another theme.
@ -45,12 +43,12 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
'post_excerpt' => 'Description of my template',
'tax_input' => array(
'wp_theme' => array(
get_stylesheet(),
self::$test_theme,
),
),
);
self::$post = self::factory()->post->create_and_get( $args );
wp_set_post_terms( self::$post->ID, get_stylesheet(), 'wp_theme' );
wp_set_post_terms( self::$post->ID, self::$test_theme, 'wp_theme' );
// Set up template part post.
$template_part_args = array(
@ -61,7 +59,7 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
'post_excerpt' => 'Description of my template part',
'tax_input' => array(
'wp_theme' => array(
get_stylesheet(),
self::$test_theme,
),
'wp_template_part_area' => array(
WP_TEMPLATE_PART_AREA_HEADER,
@ -70,7 +68,12 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
);
self::$template_part_post = self::factory()->post->create_and_get( $template_part_args );
wp_set_post_terms( self::$template_part_post->ID, WP_TEMPLATE_PART_AREA_HEADER, 'wp_template_part_area' );
wp_set_post_terms( self::$template_part_post->ID, get_stylesheet(), 'wp_theme' );
wp_set_post_terms( self::$template_part_post->ID, self::$test_theme, 'wp_theme' );
}
public function set_up() {
parent::set_up();
switch_theme( self::$test_theme );
}
public static function wpTearDownAfterClass() {
@ -225,9 +228,7 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
* Should retrieve the template from the theme files.
*/
function test_get_block_template_from_file() {
$this->markTestIncomplete();
// Requires switching to a block theme.
/* $id = get_stylesheet() . '//' . 'index';
$id = get_stylesheet() . '//' . 'index';
$template = get_block_template( $id, 'wp_template' );
$this->assertSame( $id, $template->id );
$this->assertSame( get_stylesheet(), $template->theme );
@ -237,16 +238,15 @@ class Tests_Block_Template_Utils extends WP_UnitTestCase {
$this->assertSame( 'wp_template', $template->type );
// Test template parts.
$id = get_stylesheet() . '//' . 'header';
$id = get_stylesheet() . '//' . 'small-header';
$template = get_block_template( $id, 'wp_template_part' );
$this->assertSame( $id, $template->id );
$this->assertSame( get_stylesheet(), $template->theme );
$this->assertSame( 'header', $template->slug );
$this->assertSame( 'small-header', $template->slug );
$this->assertSame( 'publish', $template->status );
$this->assertSame( 'theme', $template->source );
$this->assertSame( 'wp_template_part', $template->type );
$this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template->area );
*/
}
/**