Block Hooks: Make test a bit easier to read.

Follow-up [57668].
Props gziolo.
See #60580.

git-svn-id: https://develop.svn.wordpress.org/trunk@57676 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
bernhard-reiter 2024-02-21 10:47:49 +00:00
parent 4ba0963a1f
commit 299e2adb44

View File

@ -163,16 +163,20 @@ class Tests_Blocks_SetIgnoredHookedBlocksMetadata extends WP_UnitTestCase {
);
$filter = function ( $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block ) {
if ( 'tests/anchor-block' === $parsed_anchor_block['blockName'] && 'after' === $relative_position ) {
if (
'tests/hooked-block-suppressed-by-filter' === $hooked_block_type &&
'after' === $relative_position &&
'tests/anchor-block' === $parsed_anchor_block['blockName']
) {
return null;
}
return $parsed_hooked_block;
};
add_filter( 'hooked_block_tests/hooked-block-suppressed-by-filter', $filter, 10, 4 );
add_filter( 'hooked_block', $filter, 10, 4 );
set_ignored_hooked_blocks_metadata( $anchor_block, 'after', $hooked_blocks, null );
remove_filter( 'hooked_block_tests/hooked-block-suppressed-by-filter', $filter );
remove_filter( 'hooked_block', $filter );
$this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
}