Skip to content

Commit

Permalink
Add test coverage for theme attr insertion into patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Oct 10, 2023
1 parent 9824ee2 commit 3cb17f8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,29 @@ public function test_get_all_registered_includes_hooked_blocks() {
$this->assertSame( $expected, $registered );
}

/**
* Should insert a theme attribute into Template Part blocks in registered patterns.
*
* @ticket XXXXX
*
* @covers WP_Block_Patterns_Registry::register
* @covers WP_Block_Patterns_Registry::get_registered
*/
public function test_get_registered_includes_theme_attribute() {
$test_pattern = array(
'title' => 'Test Pattern',
'content' => '<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header"} /-->',
);
$this->registry->register( 'test/pattern', $test_pattern );

$expected = sprintf(
'<!-- wp:template-part {"slug":"header","align":"full","tagName":"header","className":"site-header","theme":"%s"} /-->',
get_stylesheet()
);
$pattern = $this->registry->get_registered( 'test/pattern' );
$this->assertSame( $expected, $pattern['content'] );
}

/**
* Should insert hooked blocks into registered patterns.
*
Expand Down

0 comments on commit 3cb17f8

Please sign in to comment.