WordPress Help
Official documentation, learning resources, and contributor guides collected from WordPress.org.
-
When /^I (run|try) the previous command again$/
Run or try the previous command again. Usage run expects an exit code 0, whereas try allows for non-zero exit codes. Scenario: My example scenario When I run `wp site option update admin_user_id 1` Then STDOUT should contain: “”” Success: Updated ‘admin_user_id’ site option. “”” When I run the previous command again Then STDOUT should…
-
When /^I (run|try) `([^`]+)`$/
Run or try a given command. Usage run expects an exit code 0, whereas try allows for non-zero exit codes. So if using run and the command errors, the step will fail. Scenario: My example scenario When I run `wp core version` Then STDOUT should contain: “”” 6.8 “”” Scenario: My other scenario When I…
-
Then /^(STDOUT|STDERR) should( strictly)? (be|contain|not contain):$/
Check the contents of STDOUT or STDERR. Usage Scenario: My example scenario Given an empty directory When I run `wp core is-installed` Then STDOUT should be empty Scenario: My other scenario Given a WP install When I run `wp plugin install akismet` Then STDOUT should contain: “”” Plugin installed successfully. “”” And STDERR should be…
-
Then /^STDOUT should be a table containing rows:$/
Expect STDOUT to be a table containing the given rows. Usage Scenario: My example scenario Given a WP installation When I run `wp config list –fields=name,type` Then STDOUT should be a table containing rows: | name | type | | DB_NAME | constant | | DB_USER | constant | Behat steps documentation is generated from…
-
Then /^the contents of the (.+) file should( not)? match (((/.+/)|(#.+#))([a-z]+)?)$/
Match file contents against a regex. Usage Scenario: My example scenario When I run `wp scaffold plugin hello-world` Then the contents of the wp-content/plugins/hello-world/languages/hello-world.pot file should match /X-Generator:\s/ Behat steps documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request. Related Then /^the return code should( not)?…
-
Then /^the (.+) (file|directory) should( strictly)? (exist|not exist|be:|contain:|not contain:)$/
Expect a certain file or directory to (not) exist or (not) contain certain contents. Usage Scenario: My example scenario When I run `wp core download` Then the wp-settings.php file should exist And the wp-content directory should exist And the {RUN_DIR} directory should contain: “”” index.php license.txt “”” And the wp-config.php file should contain: “”” That’s…
-
Then /^STDOUT should be CSV containing:$/
Expect STDOUT to be CSV containing certain values. Usage Scenario: My example scenario When I run `wp term list post_tag –fields=name,slug –format=csv` Then STDOUT should be CSV containing: | name | slug | | Test term | test | Behat steps documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please…
-
Then /^STDOUT should be JSON containing:$/
Expect valid JSON output in STDOUT. Usage Scenario: My example scenario When I run `wp post meta get 1 meta-key –format=json` Then STDOUT should be JSON containing: “”” { “foo”: “baz” } “”” Behat steps documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request. Related Then…
-
Then /^STDOUT should be YAML containing:$/
Expect STDOUT to be YAML containing certain content. Usage Scenario: My example scenario When I run `wp cli alias list` Then STDOUT should be YAML containing: “”” @all: Run command against every registered alias. @foo: path: {TEST_DIR}/foo “”” Behat steps documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit…
-
Then /^STDOUT should end with a table containing rows:$/
Expect STDOUT to end with a table containing the given rows. Usage Useful when the table is preceded by some other output. Scenario: My example scenario Given a WP installation When I run `wp search-replace foo bar –report-changed-only` Then STDOUT should contain: “”” Success: Made 3 replacements. “”” And STDOUT should end with a table…