Skip to content

Commit

Permalink
Add test coverage for theme attr injection in get_all_registered
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Oct 10, 2023
1 parent 3c849c0 commit d077949
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 @@ -316,6 +316,29 @@ public function test_get_registered() {
$this->assertSame( $pattern_two, $pattern );
}

/**
* 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_all_registered
*/
public function test_get_all_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()
);
$patterns = $this->registry->get_all_registered();
$this->assertSame( $expected, $patterns[0]['content'] );
}

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

0 comments on commit d077949

Please sign in to comment.