Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix get_hooked_block_markup tests
  • Loading branch information
ockham committed Jan 3, 2024
commit 4ac28f91a12a5419ee071dcd88e608b1d0d3edfb
18 changes: 15 additions & 3 deletions tests/phpunit/tests/blocks/getHookedBlockMarkup.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ class Tests_Blocks_GetHookedBlockMarkup extends WP_UnitTestCase {
* @covers ::get_hooked_block_markup
*/
public function test_get_hooked_block_markup_adds_metadata() {
$hooked_block = array(
'blockName' => 'tests/hooked-block',
);

$anchor_block = array(
'blockName' => 'tests/anchor-block',
);

$actual = get_hooked_block_markup( $anchor_block, 'tests/hooked-block' );
$actual = get_hooked_block_markup( $hooked_block, $anchor_block );
$this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
$this->assertSame( '<!-- wp:tests/hooked-block /-->', $actual );
}
Expand All @@ -32,6 +36,10 @@ public function test_get_hooked_block_markup_adds_metadata() {
* @covers ::get_hooked_block_markup
*/
public function test_get_hooked_block_markup_if_block_is_already_hooked() {
$hooked_block = array(
'blockName' => 'tests/hooked-block',
);

$anchor_block = array(
'blockName' => 'tests/anchor-block',
'attrs' => array(
Expand All @@ -41,7 +49,7 @@ public function test_get_hooked_block_markup_if_block_is_already_hooked() {
),
);

$actual = get_hooked_block_markup( $anchor_block, 'tests/hooked-block' );
$actual = get_hooked_block_markup( $hooked_block, $anchor_block );
$this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
$this->assertSame( '', $actual );
}
Expand All @@ -52,6 +60,10 @@ public function test_get_hooked_block_markup_if_block_is_already_hooked() {
* @covers ::get_hooked_block_markup
*/
public function test_get_hooked_block_markup_adds_to_ignored_hooked_blocks() {
$other_hooked_block = array(
'blockName' => 'tests/other-hooked-block',
);

$anchor_block = array(
'blockName' => 'tests/anchor-block',
'attrs' => array(
Expand All @@ -61,7 +73,7 @@ public function test_get_hooked_block_markup_adds_to_ignored_hooked_blocks() {
),
);

$actual = get_hooked_block_markup( $anchor_block, 'tests/other-hooked-block' );
$actual = get_hooked_block_markup( $other_hooked_block, $anchor_block );
$this->assertSame( array( 'tests/hooked-block', 'tests/other-hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
$this->assertSame( '<!-- wp:tests/other-hooked-block /-->', $actual );
}
Expand Down