Skip to content

Commit c249294

Browse files
claudeswissspidy
andcommitted
Cover the block version guards on WordPress 4.9
The functional test matrix runs WordPress 4.9, so the `wp post has-block` guard can be asserted directly. The scenario also pins the deliberate asymmetry between the two subcommands: `wp post has-blocks` keeps working because it goes through the bundled WP_Block_Processor polyfill, while `wp post has-block` depends on the WordPress 5.0 `has_block()` function and now reports that requirement instead of fataling. The WordPress 5.3.1 `serialize_blocks()` guard cannot be covered the same way. It only triggers between WordPress 5.0 and 5.3.0, and the matrix runs 4.9, 6.9, latest and trunk, so a scenario for it would never execute. Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
1 parent f7441a8 commit c249294

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎features/post-block.feature‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ Feature: Manage blocks in post content
4747
"""
4848
And the return code should be 1
4949

50+
@less-than-wp-5.0
51+
Scenario: Checking for a specific block requires WordPress 5.0
52+
Given a WP install
53+
When I run `wp post create --post_title="Block Post" --post_content="<!-- wp:paragraph --><p>Hello</p><!-- /wp:paragraph -->" --porcelain`
54+
Then save STDOUT as {POST_ID}
55+
56+
# has-blocks goes through the bundled WP_Block_Processor polyfill, so it keeps working.
57+
When I run `wp post has-blocks {POST_ID}`
58+
Then STDOUT should contain:
59+
"""
60+
Success: Post {POST_ID} contains blocks.
61+
"""
62+
63+
# has-block relies on the has_block() function that WordPress only added in 5.0.
64+
When I try `wp post has-block {POST_ID} core/paragraph`
65+
Then STDERR should contain:
66+
"""
67+
Error: Requires WordPress 5.0 or greater.
68+
"""
69+
And the return code should be 1
70+
5071
@require-wp-5.0
5172
Scenario: Parse blocks in a post
5273
Given a WP install

0 commit comments

Comments
 (0)