self::run_sql( "DROP DATABASE IF EXISTS $dbname" );
}
- private function _run( $command, $assoc_args ) {
+ private function _run( $command, $assoc_args, $subdir = '' ) {
if ( !empty( $assoc_args ) )
$command .= \WP_CLI\Utils\assoc_args_to_str( $assoc_args );
+ $subdir = $this->get_path( $subdir );
+
$cmd = __DIR__ . "/../../bin/wp $command";
$descriptors = array(
2 => array( 'pipe', 'w' ),
);
- $proc = proc_open( $cmd, $descriptors, $pipes, $this->install_dir );
+ $proc = proc_open( $cmd, $descriptors, $pipes, $subdir );
$STDOUT = stream_get_contents( $pipes[1] );
fclose( $pipes[1] );
return $r;
}
- public function run( $command, $assoc_args = array() ) {
+ public function run( $command, $assoc_args = array(), $subdir = '' ) {
if ( isset( self::$additional_args[ $command ] ) ) {
$assoc_args = array_merge( self::$additional_args[ $command ],
$assoc_args );
}
- return $this->_run( $command, $assoc_args );
+ return $this->_run( $command, $assoc_args, $subdir );
}
public function move_files( $src, $dest ) {
$this->create_db();
$this->create_empty_dir();
$this->download_wordpress_files( $subdir );
- $this->run( 'core config', array( 'path' => $subdir ) );
- $this->run( 'core install', array( 'path' => $subdir ) );
+ $this->run( 'core config', array(), $subdir );
+ $this->run( 'core install', array(), $subdir );
}
}
}
);
+$steps->When( "/^I run `wp (.+)` from '([^\s]+)'$/",
+ function ( $world, $cmd, $subdir ) {
+ $world->result = $world->run( $world->replace_variables( $cmd ), array(), $subdir );
+ }
+);
+
$steps->When( '/^I run the previous command again$/',
function ( $world ) {
if ( !isset( $world->result ) )