);
private $install_dir;
+ private $additional_args;
public $variables = array();
public function __construct( array $parameters )
{
$this->drop_db();
+
+ $this->additional_args = array(
+ 'core config' => self::$db_settings,
+
+ 'core install' => array(
+ 'url' => 'http://example.com',
+ 'title' => 'WP CLI Site',
+ 'admin_email' => 'admin@example.com',
+ 'admin_password' => 'password1'
+ ),
+
+ 'core install-network', array(
+ 'title' => 'WP CLI Network'
+ )
+ );
}
public function getStepDefinitionResources()
}
public function run( $command, $assoc_args = array() ) {
- switch ( $command ) {
- case 'core install':
- return $this->run_install();
- break;
-
- case 'core config':
- return $this->create_config();
- break;
-
- default:
- return $this->_run( $command, $assoc_args );
+ if ( isset( $this->additional_args[ $command ] ) ) {
+ $assoc_args = array_merge( $this->additional_args[ $command ],
+ $assoc_args );
}
- }
- public function create_config() {
- return $this->_run( 'core config', self::$db_settings );
+ return $this->_run( $command, $assoc_args );
}
public function define_custom_wp_content_dir() {
$wp_config_code = str_replace( $token, "$line\n\n$token", $wp_config_code );
}
- public function run_install() {
- return $this->_run( 'core install', array(
- 'url' => 'http://example.com',
- 'title' => 'WP CLI Site',
- 'admin_email' => 'admin@example.com',
- 'admin_password' => 'password1'
- ) );
- }
-
- public function run_install_network() {
- return $this->_run( 'core install-network', array(
- 'title' => 'WP CLI Network'
- ) );
- }
-
public function download_wordpress_files() {
// We cache the results of "wp core download" to improve test performance
// Ideally, we'd cache at the HTTP layer for more reliable tests
$steps->Given( '/^wp-config\.php$/',
function ( $world ) {
- $world->create_config();
+ $world->run( 'core config' );
}
);
$world->create_db();
$world->create_empty_dir();
$world->download_wordpress_files();
- $world->create_config();
- $world->run_install();
+ $world->run( 'core config' );
+ $world->run( 'core install' );
if ( 'multisite install' == $type ) {
- $world->run_install_network();
+ $world->run( 'core install-network' );
}
}
);