PHP Class Codeception\Module\WPCLI

Wraps calls to the wp-cli tool.
Inheritance: extends Codeception\Module
Mostrar archivo Open project: lucatume/wp-browser

Protected Properties

Property Type Description
$bootPath string
$config array
$executor tad\WPBrowser\Environment\Executor
$options array
$prettyName string
$requiredFields {
$wpCliRoot string

Public Methods

Method Description
__construct ( Codeception\Lib\ModuleContainer $moduleContainer, null | array $config, tad\WPBrowser\Environment\Executor $executor = null ) WPCLI constructor.
cli ( string $userCommand = 'core version', &$output = [] ) : integer Executes a wp-cli command.
cliToArray ( string $userCommand = 'post list --format=ids', callable $splitCallback = null ) : array Returns the output of a wp-cli command as an array.

Protected Methods

Method Description
buildCommand ( $userCommand ) : string
debugSection ( string $title, string $message )
evaluateStatus ( &$output, $status )
initPaths ( )
initWpCliPaths ( ) Initializes the wp-cli root location.
mergeCommandOptions ( string $userCommand ) : string

Method Details

__construct() public method

WPCLI constructor.
public __construct ( Codeception\Lib\ModuleContainer $moduleContainer, null | array $config, tad\WPBrowser\Environment\Executor $executor = null )
$moduleContainer Codeception\Lib\ModuleContainer
$config null | array
$executor tad\WPBrowser\Environment\Executor

buildCommand() protected method

protected buildCommand ( $userCommand ) : string
$userCommand
return string

cli() public method

The method is a wrapper around isolated calls to the wp-cli tool. The library will use its own wp-cli version to run the commands.
public cli ( string $userCommand = 'core version', &$output = [] ) : integer
$userCommand string The string of command and parameters as it would be passed to wp-cli e.g. a terminal call like `wp core version` becomes `core version` omitting the call to wp-cli script.
return integer wp-cli exit value for the command

cliToArray() public method

This method should be used in conjuction with wp-cli commands that will return lists. E.g. $inactiveThemes = $I->cliToArray('theme list --status=inactive --field=name'); The above command could return an array like ['twentyfourteen', 'twentyfifteen'] No check will be made on the command the user inserted for coherency with a split-able output.
public cliToArray ( string $userCommand = 'post list --format=ids', callable $splitCallback = null ) : array
$userCommand string
$splitCallback callable
return array An array containing the output of wp-cli split into single elements.

debugSection() protected method

protected debugSection ( string $title, string $message )
$title string
$message string

evaluateStatus() protected method

protected evaluateStatus ( &$output, $status )
$output
$status

initPaths() protected method

protected initPaths ( )

initWpCliPaths() protected method

The way the location works is an ugly hack that assumes the folder structure of the code to climb the tree and find the root folder.
protected initWpCliPaths ( )

mergeCommandOptions() protected method

protected mergeCommandOptions ( string $userCommand ) : string
$userCommand string
return string

Property Details

$bootPath protected_oe property

protected string $bootPath
return string

$config protected_oe property

protected array $config
return array

$executor protected_oe property

protected Executor,tad\WPBrowser\Environment $executor
return tad\WPBrowser\Environment\Executor

$options protected_oe property

protected array $options
return array

$prettyName protected_oe property

protected string $prettyName
return string

$requiredFields protected_oe property

{
protected $requiredFields

$wpCliRoot protected_oe property

protected string $wpCliRoot
return string