Skip to content

Commit

Permalink
Add test coverage for non-block content
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Feb 18, 2025
1 parent 0d64b60 commit 097d0c6
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Tests_Blocks_ApplyBlockHooksToContentFromPostObject extends WP_UnitTestCas
*/
protected static $post_with_ignored_hooked_block;

/**
* Post object.
*
* @var WP_Post
*/
protected static $post_with_non_block_content;

/**
*
* Set up.
Expand Down Expand Up @@ -55,6 +62,15 @@ public static function wpSetUpBeforeClass() {
)
);

self::$post_with_non_block_content = self::factory()->post->create_and_get(
array(
'post_type' => 'post',
'post_status' => 'publish',
'post_title' => 'Test Post',
'post_content' => '<h1>Hello World!</h1>',
)
);

register_block_type(
'tests/hooked-block',
array(
Expand Down Expand Up @@ -113,4 +129,16 @@ public function test_apply_block_hooks_to_content_from_post_object_respects_igno
);
$this->assertSame( $expected, $actual );
}

/**
* @ticket 62716
*/
public function test_apply_block_hooks_to_content_from_post_object_preserves_non_block_content() {
$actual = apply_block_hooks_to_content_from_post_object(
self::$post_with_non_block_content->post_content,
self::$post_with_non_block_content,
'insert_hooked_blocks'
);
$this->assertSame( self::$post_with_non_block_content->post_content, $actual );
}
}

0 comments on commit 097d0c6

Please sign in to comment.