mirror of
https://github.com/moparisthebest/wallabag
synced 2024-12-18 13:42:17 -05:00
Use sqlite test db
This commit is contained in:
parent
b30f5bd72d
commit
bc1a3342c3
@ -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>");
|
||||||
}
|
}
|
||||||
|
@ -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 (
|
||||||
|
@ -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(
|
||||||
|
27
tests/functionals/PocheWebTestCase.php
Normal file
27
tests/functionals/PocheWebTestCase.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user