Skip to content

Commit 6e12f44

Browse files
committed
Add test coverage for filter-added hooked block before Post Content
1 parent 999392c commit 6e12f44

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/phpunit/tests/blocks/applyBlockHooksToContentFromPostObject.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,33 @@ public function test_apply_block_hooks_to_content_from_post_object_respects_igno
140140
$this->assertSame( $expected, $actual );
141141
}
142142

143+
/**
144+
* @ticket 63287
145+
*/
146+
public function test_apply_block_hooks_to_content_from_post_object_does_not_insert_hooked_block_before_container_block() {
147+
$filter = function ( $hooked_block_types, $relative_position, $anchor_block_type ) {
148+
if ( 'core/post-content' === $anchor_block_type && 'before' === $relative_position ) {
149+
$hooked_block_types[] = 'tests/dynamically-hooked-block-before-post-content';
150+
}
151+
152+
return $hooked_block_types;
153+
};
154+
155+
$expected = '<!-- wp:tests/hooked-block-first-child /-->' .
156+
self::$post->post_content .
157+
'<!-- wp:tests/hooked-block /-->';
158+
159+
add_filter( 'hooked_block_types', $filter, 10, 3 );
160+
$actual = apply_block_hooks_to_content_from_post_object(
161+
self::$post->post_content,
162+
self::$post,
163+
'insert_hooked_blocks'
164+
);
165+
remove_filter( 'hooked_block_types', $filter, 10 );
166+
167+
$this->assertSame( $expected, $actual );
168+
}
169+
143170
/**
144171
* @ticket 62716
145172
*/

0 commit comments

Comments
 (0)