From bc1a3342c34f103d2b9852c1c6ae3c5d23309c5d Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Sat, 23 Nov 2013 10:44:05 +0100 Subject: [PATCH] Use sqlite test db --- src/Poche/Command/CreateSchemaCommand.php | 2 +- src/Poche/Schema.php | 12 +++++++++- tests/functionals/ApiTest.php | 18 +++------------ tests/functionals/PocheWebTestCase.php | 27 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 tests/functionals/PocheWebTestCase.php 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; + } +}