1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-12-18 05:32:23 -05:00

Use sqlite test db

This commit is contained in:
Vincent Jousse 2013-11-23 10:44:05 +01:00
parent b30f5bd72d
commit bc1a3342c3
4 changed files with 42 additions and 17 deletions

View File

@ -28,7 +28,7 @@ class CreateSchemaCommand extends BaseCommand
$app = $this->getSilexApplication(); $app = $this->getSilexApplication();
$db = $app['db']; $db = $app['db'];
Schema::executeSchema($db); Schema::createTables($db);
$output->writeln("<info>Schema created</info>"); $output->writeln("<info>Schema created</info>");
} }

View File

@ -5,7 +5,17 @@ use Poche\Util\Token;
class Schema 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(" $db->query("
CREATE TABLE config ( CREATE TABLE config (

View File

@ -1,30 +1,18 @@
<?php <?php
namespace Poche\Tests\Functionals; namespace Poche\Tests\Functionals;
use Silex\WebTestCase; require __DIR__.'/PocheWebTestCase.php';
class ApiTest extends WebTestCase
class ApiTest extends PocheWebTestCase
{ {
public function createApplication()
{
require __DIR__.'/../../app/app.php';
require __DIR__ . '/../../app/controllers/controllers.php';
$app['debug'] = true;
return $app;
}
public function testGetEntries() public function testGetEntries()
{ {
$client = $this->createClient(); $client = $this->createClient();
$crawler = $client->request('GET', '/api/entries'); $crawler = $client->request('GET', '/api/entries');
echo($client->getResponse()->getContent());die;
$this->assertTrue($client->getResponse()->isOk()); $this->assertTrue($client->getResponse()->isOk());
// Assert that the "Content-Type" header is "application/json" // Assert that the "Content-Type" header is "application/json"
$this->assertTrue( $this->assertTrue(
$client->getResponse()->headers->contains( $client->getResponse()->headers->contains(

View File

@ -0,0 +1,27 @@
<?php
namespace Poche\Tests\Functionals;
use Silex\WebTestCase;
use Poche\Schema;
class PocheWebTestCase extends WebTestCase
{
public function createApplication()
{
require __DIR__.'/../../app/app.php';
require __DIR__ . '/../../app/controllers/controllers.php';
$app['db.options'] = array(
'driver' => 'pdo_sqlite',
'path' => __DIR__.'/poche_test.db'
);
$app['debug'] = true;
Schema::dropTables($app['db']);
Schema::createTables($app['db']);
return $app;
}
}