Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/wp-content/themes/twentytwentyone/.npmrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:group -->
<!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /-->
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- wp:template-part {"slug":"header","theme":"fake-theme","align":"full", "tagName":"header","className":"site-header"} /-->
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /-->
47 changes: 47 additions & 0 deletions tests/phpunit/tests/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,53 @@ public function test_build_block_template_result_from_file() {
$this->assertEmpty( $template_part->modified );
}

/**
* @dataProvider data_build_block_template_result_from_file_injects_theme_attribute
*/
public function test_build_block_template_result_from_file_injects_theme_attribute( $filename, $expected_content ) {
$template = _build_block_template_result_from_file(
array(
'slug' => 'single',
'path' => __DIR__ . '/../data/templates/' . $filename,
),
'wp_template'
);
$this->assertSame( $expected_content, $template->content );
}

public function data_build_block_template_result_from_file_injects_theme_attribute() {
$theme = 'block-theme';
return array(
array(
'template-with-template-part.html',
sprintf(
'<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /-->',
$theme
),
),
array(
'template-with-nested-template-part.html',
sprintf(
'<!-- wp:group -->
<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /-->
<!-- /wp:group -->',
$theme
),
),
array(
'template-with-template-part-with-existing-theme-attribute.html',
'<!-- wp:template-part {"slug":"header","theme":"fake-theme","align":"full", "tagName":"header","className":"site-header"} /-->',
),
array(
'template.html',
'<!-- wp:paragraph -->
<p>Just a paragraph</p>
<!-- /wp:paragraph -->',
),
);
}


public function test_inject_theme_attribute_in_block_template_content() {
$theme = get_stylesheet();
$content_without_theme_attribute = '<!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /-->';
Expand Down