exec( "mysql -u$dbuser -p$dbpass -e '$sql'" );
}
- protected function setUp() {
+ protected function tearDown() {
+ $dbname = self::$db_settings['dbname'];
+ $this->run_sql( "DROP DATABASE IF EXISTS $dbname" );
+ }
+
+ private function create_db() {
$dbname = self::$db_settings['dbname'];
- $this->run_sql( "DROP DATABASE $dbname" );
$this->run_sql( "CREATE DATABASE $dbname" );
}
}
break;
+ case 'database': {
+ $this->create_db();
+ }
+ break;
+
case 'wp files': {
$world['runner']->download_wordpress_files();
}
break;
case 'wp install': {
+ $this->create_db();
$world['runner']->download_wordpress_files();
$world['runner']->create_config( self::$db_settings );
$world['runner']->run_install();
}
/** @scenario */
+ public function dbDoesntExist() {
+ $this
+ ->given( 'empty dir' )
+ ->and( 'wp files' )
+ ->and( 'wp config' )
+
+ ->when( 'invoking', 'wp' )
+ ->then( 'return code should be', 1 )
+ ->and( 'output should be', "Error: Can't connect to the database." )
+
+ ->when( 'invoking', 'db create' )
+ ->then( 'return code should be', 0 );
+ }
+
+ /** @scenario */
public function dbTablesNotInstalled() {
$this
->given( 'empty dir' )
->and( 'wp files' )
->and( 'wp config' )
+ ->and( 'database' )
->when( 'invoking', 'core is-installed' )
->then( 'return code should be', 1 )
->then( 'return code should be', 0 )
->when( 'invoking', 'post list --ids' )
- ->then( 'output should be', 1 );
+ ->then( 'output should be', "1" );
}
/** @scenario */