Skip to content

Commit

Permalink
Address the feedback from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Sep 18, 2023
1 parent d772493 commit d2cfe58
Showing 1 changed file with 25 additions and 45 deletions.
70 changes: 25 additions & 45 deletions tests/phpunit/tests/blocks/blockHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,8 @@ public function test_get_hooked_blocks_no_match_found() {
* @ticket 59313
*
* @covers ::get_hooked_blocks
*
* @dataProvider data_block_hooked_blocks
*
* @param string $block_name Block name.
* @param array $expected Expected hooked blocks.
*/
public function test_get_hooked_blocks_matches_found( $block_name, $expected ) {
public function test_get_hooked_blocks_matches_found() {
register_block_type(
'tests/my-block',
array(
Expand All @@ -72,49 +67,34 @@ public function test_get_hooked_blocks_matches_found( $block_name, $expected ) {
);

$this->assertSame(
$expected,
get_hooked_blocks( $block_name )
);
}

/**
* Data provider for hooked blocks.
*
* @return array {
* @type array {
* @type string Block name.
* @type array Expected hooked blocks.
* }
* }
*/
public function data_block_hooked_blocks() {
return array(
'block hooked at the before position' => array(
'tests/hooked-before',
array(
'tests/my-block' => 'before',
'tests/my-container-block' => 'before',
),
array(
'tests/my-block' => 'before',
'tests/my-container-block' => 'before',
),
'block hooked at the after position' => array(
'tests/hooked-after',
array(
'tests/my-block' => 'after',
'tests/my-container-block' => 'after',
),
get_hooked_blocks( 'tests/hooked-before' ),
'block hooked at the before position'
);
$this->assertSame(
array(
'tests/my-block' => 'after',
'tests/my-container-block' => 'after',
),
'block hooked at the first child position' => array(
'tests/hooked-first-child',
array(
'tests/my-container-block' => 'first_child',
),
get_hooked_blocks( 'tests/hooked-after' ),
'block hooked at the after position'
);
$this->assertSame(
array(
'tests/my-container-block' => 'first_child',
),
'block hooked at the last child position' => array(
'tests/hooked-last-child',
array(
'tests/my-container-block' => 'last_child',
),
get_hooked_blocks( 'tests/hooked-first-child' ),
'block hooked at the first child position'
);
$this->assertSame(
array(
'tests/my-container-block' => 'last_child',
),
get_hooked_blocks( 'tests/hooked-last-child' ),
'block hooked at the last child position'
);
}
}

0 comments on commit d2cfe58

Please sign in to comment.