|
11 | 11 | * @group block-hooks |
12 | 12 | */ |
13 | 13 | 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 | + |
14 | 29 | /** |
15 | 30 | * @ticket 60126 |
16 | 31 | * |
17 | 32 | * @covers ::insert_hooked_blocks |
18 | 33 | */ |
19 | 34 | public function test_insert_hooked_blocks() { |
20 | | - $anchor_block_name = 'tests/anchor-block'; |
21 | 35 | $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, |
31 | 37 | ); |
32 | 38 |
|
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 ); |
36 | 42 | } |
37 | 43 | } |
0 commit comments