mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Blocks: Have get_hooked_blocks() return blocks grouped by position.
All existing calls of `get_hooked_blocks()` in non-test code are currently wrapped in an extra `array_keys()` call. This changeset absorbs that logic into the function and changes the structure of the return value accordingly. Furthermore, this allows us to remove the extra `$relative_position` argument (introduced in [56673]) from the function again, as the same data can now be simply fetched via array access. Props gziolo, spacedmonkey, mukesh27. See #59383. git-svn-id: https://develop.svn.wordpress.org/trunk@56704 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -70,48 +70,53 @@ class Tests_Blocks_BlockHooks extends WP_UnitTestCase {
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'tests/injected-one' => 'before',
|
||||
'tests/injected-two' => 'before',
|
||||
'before' => array(
|
||||
'tests/injected-one',
|
||||
'tests/injected-two',
|
||||
),
|
||||
),
|
||||
get_hooked_blocks( 'tests/hooked-at-before' ),
|
||||
'block hooked at the before position'
|
||||
);
|
||||
$this->assertSame(
|
||||
array(
|
||||
'tests/injected-one' => 'after',
|
||||
'tests/injected-two' => 'after',
|
||||
'after' => array(
|
||||
'tests/injected-one',
|
||||
'tests/injected-two',
|
||||
),
|
||||
),
|
||||
get_hooked_blocks( 'tests/hooked-at-after' ),
|
||||
'block hooked at the after position'
|
||||
);
|
||||
$this->assertSame(
|
||||
array(
|
||||
'tests/injected-two' => 'first_child',
|
||||
'first_child' => array(
|
||||
'tests/injected-two',
|
||||
),
|
||||
),
|
||||
get_hooked_blocks( 'tests/hooked-at-first-child' ),
|
||||
'block hooked at the first child position'
|
||||
);
|
||||
$this->assertSame(
|
||||
array(
|
||||
'tests/injected-two' => 'last_child',
|
||||
'last_child' => array(
|
||||
'tests/injected-two',
|
||||
),
|
||||
),
|
||||
get_hooked_blocks( 'tests/hooked-at-last-child' ),
|
||||
'block hooked at the last child position'
|
||||
);
|
||||
$this->assertSame(
|
||||
array(
|
||||
'tests/injected-one' => 'before',
|
||||
'tests/injected-two' => 'after',
|
||||
'before' => array(
|
||||
'tests/injected-one',
|
||||
),
|
||||
'after' => array(
|
||||
'tests/injected-two',
|
||||
),
|
||||
),
|
||||
get_hooked_blocks( 'tests/hooked-at-before-and-after' ),
|
||||
'block hooked before one block and after another'
|
||||
);
|
||||
$this->assertSame(
|
||||
array(
|
||||
'tests/injected-one' => 'before',
|
||||
),
|
||||
get_hooked_blocks( 'tests/hooked-at-before-and-after', 'before' ),
|
||||
'block hooked before one block and after another, filtered for before'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user