wp-cli/wp-cli
package; this package contains the basic files to run WP-CLI and does not contain all the commands that come with a typical wp-cli installation.
If, in your tests, you require all the commands that usually come installed with WP-CLI, then you should require the wp-cli/wp-cli-bundle
package as a development dependency of your project, see below.wp plugin list --status=active
, will not work on a default installation of wp-browser and you will get the following error message:codeception/module-cli
Composer package to work when wp-browser is used with Codeception 4.0.WPBROWSER_HOST_REQUEST
environment variable.
You can detect and use that information to, as an example, use the correct database in your test site wp-config.php
file:path
required - the absolute, or relative, path to the WordPress root folder. This will be mapped to the --path
argument of the wp-cli binary. throw
- defaults to true
to throw an exception when a wp-cli command does not return an exit status of 0
; if set to false
then the exit status of the commands will be returned as is.timeout
- defaults to 60
(seconds) to set each process execution timeout to a certain value; set to null
, false
or 0
to disable timeout completely.wp-cli
as a flag or option. In the example configuration below the allow-root
flag and the some-option
option will be passed to wp-cli
directly and prepended to the command as global options.Note: these extract configuration flags and options will be prepended to all commands executed by wp-cli!
WPCLI
module using the optional env
array in the module configuration.
The example configuration below shows all of them with some example values.
Most of the times you won't need any of these, but they are there for more fine-grained control over the module operations.The module is not validating the environment variables in any way! Those values will be evaluated by wp-cli at runtime and might generate errors if not correctly configured.
\Codeception\Module\array/string
$command - The command to run.wp
. For back-compatibility purposes you can still pass the commandline as a string, but the array format is the preferred and supported method.string/string/\Codeception\Module\array
$userCommand - The string of command and parameters as it would be passed to wp-cliwp
. For back-compatibility purposes you can still pass the commandline as a string, but the array format is the preferred and supported method.string/string/\Codeception\Module\array
$userCommand - The string of command and parameters as it would be passed to wp-cli\callable
$splitCallback - An optional callback function to split the results array.wp
. For back-compatibility purposes you can still pass the commandline as a string, but the array format is the preferred and supported method.string/\Codeception\Module\array
$userCommand - The string of command and parameters as it would be passed to wp-clistring
$text - The text to assert is not in the output.string
$text - The text to assert is in the output.int
$code - The desired result code.int
$code - The result code the command should not have exited with.string
$regex - The regex pattern, including delimiters, to assert the output matches against.