Added temporary database

This commit is contained in:
Sergio Brighenti 2020-09-27 15:47:19 +02:00
parent 9de27e1278
commit f2523c24e5
4 changed files with 23 additions and 19 deletions

View file

@ -3,6 +3,7 @@
namespace Tests;
use App\Database\Migrator;
use GuzzleHttp\Psr7\ServerRequest;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Response;
@ -12,7 +13,11 @@ class Client extends AbstractBrowser
protected function doRequest($request)
{
/** @var \Slim\App $app */
$app = require_once BASE_DIR.'bootstrap/app.php';
$app = require BASE_DIR.'bootstrap/app.php';
$migrator = new Migrator($app->getContainer()->get('database'), BASE_DIR.'resources/schemas');
$migrator->migrate();
$response = $app->handle(new ServerRequest($request->getMethod(), $request->getUri(), [], $request->getContent()));
return new Response($response->getBody()->getContents(), $response->getStatusCode(), $response->getHeaders());

View file

@ -2,6 +2,6 @@
define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR);
define('PLATFORM_VERSION', json_decode(file_get_contents(BASE_DIR.'composer.json'))->version);
define('CONFIG_FILE', BASE_DIR.'tests/config_test.php');
define('CONFIG_FILE', BASE_DIR.'tests/config.test.php');
ob_start();

16
tests/config.test.php Normal file
View file

@ -0,0 +1,16 @@
<?php
return [
'base_path' => 'http://localhost',
'debug' => true,
'db' =>
[
'connection' => 'sqlite',
'dsn' => ':memory:',
],
'storage' =>
[
'driver' => 'local',
'path' => 'storage/test',
],
];

View file

@ -1,17 +0,0 @@
<?php
return [
'debug' => true,
// 'db' =>
// [
// 'connection' => 'sqlite',
// 'dsn' => ':memory:',
// 'username' => null,
// 'password' => null,
// ],
'storage' =>
[
'driver' => 'local',
'path' => 'storage/test',
],
];