Skip to content

Commit 097d0c6

Browse files
committed
Add test coverage for non-block content
1 parent 0d64b60 commit 097d0c6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/phpunit/tests/blocks/applyBlockHooksToContentFromPostObject.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ class Tests_Blocks_ApplyBlockHooksToContentFromPostObject extends WP_UnitTestCas
2727
*/
2828
protected static $post_with_ignored_hooked_block;
2929

30+
/**
31+
* Post object.
32+
*
33+
* @var WP_Post
34+
*/
35+
protected static $post_with_non_block_content;
36+
3037
/**
3138
*
3239
* Set up.
@@ -55,6 +62,15 @@ public static function wpSetUpBeforeClass() {
5562
)
5663
);
5764

65+
self::$post_with_non_block_content = self::factory()->post->create_and_get(
66+
array(
67+
'post_type' => 'post',
68+
'post_status' => 'publish',
69+
'post_title' => 'Test Post',
70+
'post_content' => '<h1>Hello World!</h1>',
71+
)
72+
);
73+
5874
register_block_type(
5975
'tests/hooked-block',
6076
array(
@@ -113,4 +129,16 @@ public function test_apply_block_hooks_to_content_from_post_object_respects_igno
113129
);
114130
$this->assertSame( $expected, $actual );
115131
}
132+
133+
/**
134+
* @ticket 62716
135+
*/
136+
public function test_apply_block_hooks_to_content_from_post_object_preserves_non_block_content() {
137+
$actual = apply_block_hooks_to_content_from_post_object(
138+
self::$post_with_non_block_content->post_content,
139+
self::$post_with_non_block_content,
140+
'insert_hooked_blocks'
141+
);
142+
$this->assertSame( self::$post_with_non_block_content->post_content, $actual );
143+
}
116144
}

0 commit comments

Comments
 (0)