Skip to content

Commit b959749

Browse files
Copilotswissspidy
andcommitted
Enhance Behat step tests with edge cases and Phar tests
Co-authored-by: swissspidy <[email protected]>
1 parent 2a78ff0 commit b959749

File tree

1 file changed

+146
-5
lines changed

1 file changed

+146
-5
lines changed

features/behat-steps.feature

Lines changed: 146 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,9 @@ Feature: Test that WP-CLI Behat steps work as expected
310310
@require-wp
311311
Scenario: Test STDOUT as table containing rows
312312
Given a WP installation
313-
When I run `wp option list --fields=option_name,option_value --format=table | head -5`
314-
Then STDOUT should not be empty
313+
When I run `wp option list --fields=option_name --format=table --orderby=option_name | head -5`
314+
Then STDOUT should be a table containing rows:
315+
| option_name |
315316

316317
@require-wp
317318
Scenario: Test JSON output
@@ -381,12 +382,19 @@ Feature: Test that WP-CLI Behat steps work as expected
381382
"""
382383

383384
@require-wp
384-
Scenario: Test WP multisite installation
385+
Scenario: Test WP multisite subdirectory installation
385386
Given a WP multisite subdirectory installation
386387
When I run `wp site list --field=url`
387388
Then STDOUT should not be empty
388389
And the return code should be 0
389390

391+
@require-wp
392+
Scenario: Test WP multisite subdomain installation
393+
Given a WP multisite subdomain installation
394+
When I run `wp site list --field=url`
395+
Then STDOUT should not be empty
396+
And the return code should be 0
397+
390398
@require-wp
391399
Scenario: Test misconfigured WP_CONTENT_DIR
392400
Given a WP installation
@@ -547,8 +555,10 @@ Feature: Test that WP-CLI Behat steps work as expected
547555
@require-wp
548556
Scenario: Test STDOUT end with table
549557
Given a WP installation
550-
When I run `wp option list --fields=option_name --format=table | head -10`
551-
Then STDOUT should not be empty
558+
When I run `wp user list --fields=user_login --format=table`
559+
Then STDOUT should end with a table containing rows:
560+
| user_login |
561+
| admin |
552562
553563
Scenario: Test combining multiple string replacements
554564
Given an empty directory
@@ -579,3 +589,134 @@ Feature: Test that WP-CLI Behat steps work as expected
579589
"""
580590
Then the relative.txt file should exist
581591
And the {RUN_DIR}/relative.txt file should exist
592+
593+
@require-phar
594+
Scenario: Test new Phar with specific version
595+
Given an empty directory
596+
And a new Phar with version "2.11.0"
597+
Then the wp-cli.phar file should exist
598+
599+
@require-phar
600+
Scenario: Test new Phar with same version
601+
Given an empty directory
602+
And a new Phar with the same version
603+
Then the wp-cli.phar file should exist
604+
605+
@require-phar-download
606+
Scenario: Test downloaded Phar with specific version
607+
Given an empty directory
608+
And a downloaded Phar with version "2.11.0"
609+
Then the wp-cli.phar file should exist
610+
611+
@require-phar-download
612+
Scenario: Test downloaded Phar with same version
613+
Given an empty directory
614+
And a downloaded Phar with the same version
615+
Then the wp-cli.phar file should exist
616+
617+
Scenario: Test variable naming conventions
618+
When I run `echo "value1"`
619+
Then save STDOUT as {VAR_NAME}
620+
621+
When I run `echo {VAR_NAME}`
622+
Then STDOUT should be:
623+
"""
624+
value1
625+
"""
626+
627+
Scenario: Test variable with underscore prefix
628+
When I run `echo "value2"`
629+
Then save STDOUT as {_UNDERSCORE_VAR}
630+
631+
When I run `echo {_UNDERSCORE_VAR}`
632+
Then STDOUT should contain:
633+
"""
634+
value2
635+
"""
636+
637+
Scenario: Test variable with numbers
638+
When I run `echo "value3"`
639+
Then save STDOUT as {VAR123}
640+
641+
When I run `echo {VAR123}`
642+
Then STDOUT should contain:
643+
"""
644+
value3
645+
"""
646+
647+
Scenario: Test built-in variables
648+
When I run `echo {RUN_DIR}`
649+
Then STDOUT should not be empty
650+
And STDOUT should not contain:
651+
"""
652+
{RUN_DIR}
653+
"""
654+
655+
Scenario: Test CACHE_DIR variable
656+
Given an empty cache
657+
When I run `echo {SUITE_CACHE_DIR}`
658+
Then STDOUT should not be empty
659+
And STDOUT should not contain:
660+
"""
661+
{SUITE_CACHE_DIR}
662+
"""
663+
664+
Scenario: Test multiline STDOUT capture
665+
When I run `printf "line1\nline2\nline3"`
666+
Then STDOUT should contain:
667+
"""
668+
line1
669+
"""
670+
And STDOUT should contain:
671+
"""
672+
line2
673+
"""
674+
And STDOUT should contain:
675+
"""
676+
line3
677+
"""
678+
679+
Scenario: Test STDERR capture
680+
When I try `bash -c 'echo "stdout"; echo "stderr" >&2'`
681+
Then STDOUT should contain:
682+
"""
683+
stdout
684+
"""
685+
And STDERR should contain:
686+
"""
687+
stderr
688+
"""
689+
690+
Scenario: Test file with multiline content
691+
Given an empty directory
692+
And a multiline.txt file:
693+
"""
694+
First line
695+
Second line
696+
Third line
697+
"""
698+
Then the multiline.txt file should contain:
699+
"""
700+
First line
701+
"""
702+
And the multiline.txt file should contain:
703+
"""
704+
Second line
705+
"""
706+
And the multiline.txt file should contain:
707+
"""
708+
Third line
709+
"""
710+
711+
Scenario: Test return code not be assertion
712+
When I run `true`
713+
Then the return code should not be 1
714+
And the return code should not be 2
715+
716+
@require-wp
717+
Scenario: Test CSV containing with headers
718+
Given a WP installation
719+
When I run `wp user list --fields=user_login,user_email --format=csv`
720+
Then STDOUT should be CSV containing:
721+
| user_login | user_email |
722+
| admin | [email protected] |

0 commit comments

Comments
 (0)