Skip to content

Commit 8669a32

Browse files
committed
insert_hooked_blocks Test: Turn vars into class consts
1 parent d47dba8 commit 8669a32

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

tests/phpunit/tests/blocks/insertHookedBlocks.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,33 @@
1111
* @group block-hooks
1212
*/
1313
class Tests_Blocks_InsertHookedBlocks extends WP_UnitTestCase {
14+
const ANCHOR_BLOCK_TYPE = 'tests/anchor-block';
15+
16+
const HOOKED_BLOCK_TYPE = 'tests/hooked-block';
17+
const HOOKED_BLOCK = array(
18+
'blockName' => 'tests/different-hooked-block',
19+
'attrs' => array(),
20+
'innerContent' => array(),
21+
);
22+
23+
const HOOKED_BLOCKS = array(
24+
self::ANCHOR_BLOCK_TYPE => array(
25+
'after' => array( self::HOOKED_BLOCK_TYPE ),
26+
),
27+
);
28+
1429
/**
1530
* @ticket 60126
1631
*
1732
* @covers ::insert_hooked_blocks
1833
*/
1934
public function test_insert_hooked_blocks() {
20-
$anchor_block_name = 'tests/anchor-block';
2135
$anchor_block = array(
22-
'blockName' => $anchor_block_name,
23-
);
24-
25-
// Maybe move to class level and include other relative positions?
26-
// And/or data provider?
27-
$hooked_blocks = array(
28-
$anchor_block_name => array(
29-
'after' => array( 'tests/hooked-before' ),
30-
),
36+
'blockName' => self::ANCHOR_BLOCK_TYPE,
3137
);
3238

33-
$actual = insert_hooked_blocks( $anchor_block, 'after', $hooked_blocks, array() );
34-
$this->assertSame( array( 'tests/hooked-before' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
35-
$this->assertSame( '<!-- wp:tests/hooked-before /-->', $actual );
39+
$actual = insert_hooked_blocks( $anchor_block, 'after', self::HOOKED_BLOCKS, array() );
40+
$this->assertSame( array( self::HOOKED_BLOCK_TYPE ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
41+
$this->assertSame( '<!-- wp:' . self::HOOKED_BLOCK_TYPE . ' /-->', $actual );
3642
}
3743
}

0 commit comments

Comments
 (0)