Changeset 56759
- Timestamp:
- 10/03/2023 08:27:51 AM (11 months ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 28 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/blockHooks.php
r56704 r56759 1 <?php2 /**3 * Tests for block hooks feature functions.4 *5 * @package WordPress6 * @subpackage Blocks7 *8 * @since 6.4.09 *10 * @group blocks11 */12 class Tests_Blocks_BlockHooks extends WP_UnitTestCase {13 14 /**15 * Tear down after each test.16 *17 * @since 6.4.018 */19 public function tear_down() {20 $registry = WP_Block_Type_Registry::get_instance();21 22 foreach ( array( 'tests/my-block', 'tests/my-container-block' ) as $block_name ) {23 if ( $registry->is_registered( $block_name ) ) {24 $registry->unregister( $block_name );25 }26 }27 28 parent::tear_down();29 }30 31 /**32 * @ticket 5938333 *34 * @covers ::get_hooked_blocks35 */36 public function test_get_hooked_blocks_no_match_found() {37 $result = get_hooked_blocks( 'tests/no-hooked-blocks' );38 39 $this->assertSame( array(), $result );40 }41 42 /**43 * @ticket 5938344 *45 * @covers ::get_hooked_blocks46 */47 public function test_get_hooked_blocks_matches_found() {48 register_block_type(49 'tests/injected-one',50 array(51 'block_hooks' => array(52 'tests/hooked-at-before' => 'before',53 'tests/hooked-at-after' => 'after',54 'tests/hooked-at-before-and-after' => 'before',55 ),56 )57 );58 register_block_type(59 'tests/injected-two',60 array(61 'block_hooks' => array(62 'tests/hooked-at-before' => 'before',63 'tests/hooked-at-after' => 'after',64 'tests/hooked-at-before-and-after' => 'after',65 'tests/hooked-at-first-child' => 'first_child',66 'tests/hooked-at-last-child' => 'last_child',67 ),68 )69 );70 71 $this->assertSame(72 array(73 'before' => array(74 'tests/injected-one',75 'tests/injected-two',76 ),77 ),78 get_hooked_blocks( 'tests/hooked-at-before' ),79 'block hooked at the before position'80 );81 $this->assertSame(82 array(83 'after' => array(84 'tests/injected-one',85 'tests/injected-two',86 ),87 ),88 get_hooked_blocks( 'tests/hooked-at-after' ),89 'block hooked at the after position'90 );91 $this->assertSame(92 array(93 'first_child' => array(94 'tests/injected-two',95 ),96 ),97 get_hooked_blocks( 'tests/hooked-at-first-child' ),98 'block hooked at the first child position'99 );100 $this->assertSame(101 array(102 'last_child' => array(103 'tests/injected-two',104 ),105 ),106 get_hooked_blocks( 'tests/hooked-at-last-child' ),107 'block hooked at the last child position'108 );109 $this->assertSame(110 array(111 'before' => array(112 'tests/injected-one',113 ),114 'after' => array(115 'tests/injected-two',116 ),117 ),118 get_hooked_blocks( 'tests/hooked-at-before-and-after' ),119 'block hooked before one block and after another'120 );121 }122 } -
trunk/tests/phpunit/tests/theme/themeDir.php
r56629 r56759 188 188 'Block Theme Post Content Default', 189 189 'Block Theme with defined Typography Fonts', 190 'Block Theme with Hooked Blocks', 190 191 'Empty `fontFace` in theme.json - no webfonts defined', 191 192 'A theme with the Update URI header',
Note: See TracChangeset
for help on using the changeset viewer.