Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use \WP_CLI\Process;
use \WP_CLI\Utils;

use Symfony\Component\Filesystem\Filesystem,
Symfony\Component\Filesystem\Exception\IOExceptionInterface;

// Inside a community package
if ( file_exists( __DIR__ . '/utils.php' ) ) {
require_once __DIR__ . '/utils.php';
Expand Down Expand Up @@ -44,7 +47,7 @@
*/
class FeatureContext extends BehatContext implements ClosuredContextInterface {

private static $cache_dir, $suite_cache_dir;
private static $cache_dir, $suite_cache_dir, $fs;

private static $db_settings = array(
'dbname' => 'wp_cli_test',
Expand Down Expand Up @@ -110,7 +113,7 @@ public static function prepare( SuiteEvent $event ) {
*/
public static function afterSuite( SuiteEvent $event ) {
if ( self::$suite_cache_dir ) {
Process::create( Utils\esc_cmd( 'rm -r %s', self::$suite_cache_dir ), null, self::get_process_env_variables() )->run();
self::$fs->remove( self::$suite_cache_dir );
}
}

Expand All @@ -128,13 +131,13 @@ public function afterScenario( $event ) {
if ( isset( $this->variables['RUN_DIR'] ) ) {
// remove altered WP install, unless there's an error
if ( $event->getResult() < 4 && 0 === strpos( $this->variables['RUN_DIR'], sys_get_temp_dir() ) ) {
$this->proc( Utils\esc_cmd( 'rm -rf %s', $this->variables['RUN_DIR'] ) )->run();
self::$fs->remove( $this->variables['RUN_DIR'] );
}
}

// Remove WP-CLI package directory
if ( isset( $this->variables['PACKAGE_PATH'] ) ) {
$this->proc( Utils\esc_cmd( 'rm -rf %s', $this->variables['PACKAGE_PATH'] ) )->run();
self::$fs->remove( $this->variables['PACKAGE_PATH'] );
}

foreach ( $this->running_procs as $proc ) {
Expand Down Expand Up @@ -189,6 +192,9 @@ public function __construct( array $parameters ) {
$this->drop_db();
$this->set_cache_dir();
$this->variables['CORE_CONFIG_SETTINGS'] = Utils\assoc_args_to_str( self::$db_settings );
if ( ! self::$fs ) {
self::$fs = new FileSystem;
}
}

public function getStepDefinitionResources() {
Expand Down