}
public function run( $command, $cwd = false ) {
+ switch ( $command ) {
+ case 'core install':
+ return $this->run_install();
+ break;
+
+ case 'core config':
+ return $this->create_config();
+ break;
+
+ default:
+ return $this->_run( $command, $cwd );
+ }
+ }
+
+ private function _run( $command, $cwd ) {
if ( !$cwd )
$cwd = $this->install_dir;
{
$cmd = ltrim( str_replace( 'wp', '', $cmd ) );
- switch ( $cmd )
- {
- case 'core install':
- $this->result = $this->runner->run_install();
- break;
-
- case 'core config':
- $this->result = $this->runner->create_config();
- break;
-
- default:
- $this->result = $this->runner->run( $cmd );
- }
+ $this->result = $this->runner->run( $cmd );
+ }
+
+ /**
+ * @When /^I run the previous command again$/
+ */
+ public function iRunThePreviousCommandAgain()
+ {
+ if ( !isset( $this->result ) )
+ throw new \Exception( 'No previous command.' );
+
+ $this->result = $this->runner->run( $this->result->command );
}
/**
}
/**
+ * @Then /^(STDOUT|STDERR) should match \'([^\']+)\'$/
+ */
+ public function outputShouldMatch( $stream, $format )
+ {
+ assertStringMatchesFormat( $format, $this->result->$stream );
+ }
+
+ /**
* @Then /^(STDOUT|STDERR) should not be empty$/
*/
public function outputShouldNotBeEmpty( $stream )
--- /dev/null
+Feature: Manage WordPress users
+
+ Scenario: Creating/deleting users
+ Given WP install
+
+ When I run `wp user create testuser testuser@example.com --porcelain`
+ Then the return code should be 0
+ And STDOUT should match '%d'
+
+ When I run the previous command again
+ Then the return code should be 1