diff --git a/src/Poche/Command/CreateSchemaCommand.php b/src/Poche/Command/CreateSchemaCommand.php index 645d14a..e3c5a24 100644 --- a/src/Poche/Command/CreateSchemaCommand.php +++ b/src/Poche/Command/CreateSchemaCommand.php @@ -28,7 +28,7 @@ class CreateSchemaCommand extends BaseCommand $app = $this->getSilexApplication(); $db = $app['db']; - Schema::executeSchema($db); + Schema::createTables($db); $output->writeln("Schema created"); } diff --git a/src/Poche/Schema.php b/src/Poche/Schema.php index 30b861c..534409d 100644 --- a/src/Poche/Schema.php +++ b/src/Poche/Schema.php @@ -5,7 +5,17 @@ use Poche\Util\Token; class Schema { - public static function executeSchema($db) { + + public static function dropTables($db) { + $db->query("DROP TABLE IF EXISTS config"); + $db->query("DROP TABLE IF EXISTS users"); + $db->query("DROP TABLE IF EXISTS entries"); + $db->query("DROP TABLE IF EXISTS tags"); + $db->query("DROP TABLE IF EXISTS tags_entries"); + $db->query("DROP TABLE IF EXISTS plugin_options"); + } + + public static function createTables($db) { $db->query(" CREATE TABLE config ( diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php index e42f51f..be9e1e7 100644 --- a/tests/functionals/ApiTest.php +++ b/tests/functionals/ApiTest.php @@ -1,30 +1,18 @@ createClient(); $crawler = $client->request('GET', '/api/entries'); - echo($client->getResponse()->getContent());die; - $this->assertTrue($client->getResponse()->isOk()); - // Assert that the "Content-Type" header is "application/json" $this->assertTrue( $client->getResponse()->headers->contains( diff --git a/tests/functionals/PocheWebTestCase.php b/tests/functionals/PocheWebTestCase.php new file mode 100644 index 0000000..0f0e74e --- /dev/null +++ b/tests/functionals/PocheWebTestCase.php @@ -0,0 +1,27 @@ + 'pdo_sqlite', + 'path' => __DIR__.'/poche_test.db' + ); + + $app['debug'] = true; + + Schema::dropTables($app['db']); + Schema::createTables($app['db']); + + return $app; + } +}