From 723f516bdf1ca7e4abf8c006c72085650a865757 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 10 Dec 2025 03:30:36 +0000 Subject: [PATCH 1/4] Add more edge case testing --- features/block-binding.feature | 45 ++++++++++++++++++ features/block-pattern-category.feature | 28 +++++++++++ features/block-pattern.feature | 34 +++++++++++++ features/block-style.feature | 60 +++++++++++++++++++++++ features/block-synced-pattern.feature | 63 +++++++++++++++++++++++++ features/block-template.feature | 56 ++++++++++++++++++++++ features/block-type.feature | 51 ++++++++++++++++++++ src/Block_Synced_Pattern_Command.php | 28 +++++++++++ src/Block_Template_Command.php | 36 +++++++++++--- src/Block_Type_Command.php | 8 ++++ 10 files changed, 402 insertions(+), 7 deletions(-) diff --git a/features/block-binding.feature b/features/block-binding.feature index 41a7858..d9a2d4f 100644 --- a/features/block-binding.feature +++ b/features/block-binding.feature @@ -1,5 +1,16 @@ Feature: Block binding commands + @less-than-wp-6.5 + Scenario: Block binding commands not available on WP < 6.5 + Given a WP install + + When I try `wp block binding list` + Then STDERR should contain: + """ + is not a registered wp command + """ + And the return code should be 1 + @require-wp-6.5 Scenario: List block binding sources Given a WP install @@ -36,3 +47,37 @@ Feature: Block binding commands not registered """ And the return code should be 1 + + @require-wp-6.5 + Scenario: List binding sources in various formats + Given a WP install + + When I run `wp block binding list --format=table` + Then STDOUT should be a table containing rows: + | name | + | core/post-meta | + + When I run `wp block binding list --format=yaml` + Then STDOUT should contain: + """ + name: core/post-meta + """ + + When I run `wp block binding list --format=csv` + Then STDOUT should contain: + """ + name, + """ + + @require-wp-6.5 + Scenario: Get binding source field values + Given a WP install + + When I run `wp block binding get core/post-meta --field=name` + Then STDOUT should be: + """ + core/post-meta + """ + + When I run `wp block binding get core/post-meta --field=label` + Then STDOUT should not be empty diff --git a/features/block-pattern-category.feature b/features/block-pattern-category.feature index e10a872..7f7e884 100644 --- a/features/block-pattern-category.feature +++ b/features/block-pattern-category.feature @@ -40,3 +40,31 @@ Feature: Block pattern category commands not registered """ And the return code should be 1 + + @require-wp-5.5 + Scenario: List pattern categories in various formats + Given a WP install + + When I run `wp block pattern-category list --format=table` + Then STDOUT should be a table containing rows: + | name | + | text | + + When I run `wp block pattern-category list --format=csv` + Then STDOUT should contain: + """ + name, + """ + + When I run `wp block pattern-category list --format=yaml` + Then STDOUT should contain: + """ + name: text + """ + + @require-wp-5.5 + Scenario: Get pattern category label field + Given a WP install + + When I run `wp block pattern-category get text --field=label` + Then STDOUT should not be empty diff --git a/features/block-pattern.feature b/features/block-pattern.feature index 83fd1f7..b03daff 100644 --- a/features/block-pattern.feature +++ b/features/block-pattern.feature @@ -62,3 +62,37 @@ Feature: Block pattern commands not registered """ And the return code should be 1 + + @require-wp-5.5 + Scenario: Search patterns with no matches returns empty + Given a WP install + + When I run `wp block pattern list --search=xyznonexistent123 --format=count` + Then STDOUT should be: + """ + 0 + """ + + @require-wp-5.5 + Scenario: Get pattern content field + Given a WP install + + When I run `wp block pattern list --field=name` + Then STDOUT should not be empty + And save STDOUT '%s' as {PATTERN_NAME} + + When I run `wp block pattern get {PATTERN_NAME} --field=content` + Then STDOUT should contain: + """ +

X

' --porcelain` + Then save STDOUT as {PATTERN_ID} + + When I run `wp block synced-pattern list --format=table` + Then STDOUT should be a table containing rows: + | ID | + | {PATTERN_ID} | + + When I run `wp block synced-pattern list --format=csv` + Then STDOUT should contain: + """ + ID, + """ + + When I run `wp block synced-pattern list --format=yaml` + Then STDOUT should contain: + """ + post_title: Format Test + """ + + # Cleanup + When I run `wp block synced-pattern delete {PATTERN_ID} --force` + Then STDOUT should contain: + """ + Deleted + """ diff --git a/features/block-template.feature b/features/block-template.feature index b01478a..9f91aec 100644 --- a/features/block-template.feature +++ b/features/block-template.feature @@ -126,3 +126,59 @@ Feature: Block template commands not found """ And the return code should be 1 + + @require-wp-5.9 + Scenario: Export template to file + Given a WP install + And I try `wp theme install twentytwentyfour --activate` + + When I run `wp block template list --field=id` + Then STDOUT should not be empty + And save STDOUT '%s' as {TEMPLATE_ID} + + When I run `wp block template export {TEMPLATE_ID} --file=exported-template.html` + Then STDOUT should contain: + """ + Success: + """ + And the exported-template.html file should contain: + """ +

X

' --porcelain` Then save STDOUT as {PATTERN_ID} - When I run `wp block synced-pattern list --format=table` + When I run `wp block synced-pattern list --fields=ID --format=table` Then STDOUT should be a table containing rows: | ID | | {PATTERN_ID} | diff --git a/features/block-type.feature b/features/block-type.feature index a661eb3..6d7ff52 100644 --- a/features/block-type.feature +++ b/features/block-type.feature @@ -125,7 +125,7 @@ Feature: Block type commands Scenario: List block types in various formats Given a WP install - When I run `wp block type list --format=table` + When I run `wp block type list --fields=name --format=table` Then STDOUT should be a table containing rows: | name | | core/paragraph | From a7e9371531e086bd43c7197e8a0f2ffcf4d08943 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 10 Dec 2025 10:15:55 +0000 Subject: [PATCH 4/4] Fix expected version mismatch string --- features/block-binding.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/block-binding.feature b/features/block-binding.feature index 45808dd..f8294c7 100644 --- a/features/block-binding.feature +++ b/features/block-binding.feature @@ -7,7 +7,7 @@ Feature: Block binding commands When I try `wp block binding list` Then STDERR should contain: """ - is not a registered wp command + Requires WordPress 6.5 or greater. """ And the return code should be 1