OSDN Git Service

behat: use bash function to allow inner calls to `wp`
authorscribu <mail@scribu.net>
Tue, 28 May 2013 00:03:41 +0000 (03:03 +0300)
committerscribu <mail@scribu.net>
Tue, 28 May 2013 12:46:06 +0000 (15:46 +0300)
(bash aliases seem to be available only in interactive mode)

features/bootstrap/FeatureContext.php
features/bootstrap/Process.php
features/user.feature

index 76d2343..e0478d2 100644 (file)
@@ -31,7 +31,7 @@ class FeatureContext extends BehatContext implements ClosuredContextInterface {
        public $variables = array();
 
        private static function wp_cli( $command ) {
-               return __DIR__ . "/../../bin/wp $command";
+               return "wp $command";
        }
 
        // We cache the results of `wp core download` to improve test performance
index 0776a28..4dddf42 100644 (file)
@@ -27,7 +27,13 @@ class Process {
                        2 => array( 'pipe', 'w' ),
                );
 
-               $proc = proc_open( $this->command, $descriptors, $pipes, $cwd );
+               // Ensure we're using the expected `wp` binary
+               $env = sprintf( 'function wp() { %s "$@"; }; %s',
+                       realpath( __DIR__ . "/../../bin/wp" ), $this->command );
+
+               $wrapper = sprintf( 'bash -c %s', escapeshellarg( $env ) );
+
+               $proc = proc_open( $wrapper, $descriptors, $pipes, $cwd );
 
                $STDOUT = stream_get_contents( $pipes[1] );
                fclose( $pipes[1] );
index 1e8131e..8743d12 100644 (file)
@@ -23,9 +23,7 @@ Feature: Manage WordPress users
     Given a WP install
 
     # Delete all users
-    When I run `wp user list --format=ids`
-    And save STDOUT as {USER_IDS}
-    And I run `wp user delete {USER_IDS}`
+    When I run `wp user delete $(wp user list --format=ids)`
     And I run `wp user list --format=ids`
     Then STDOUT should be empty