Removed duplicated code to define testing database connection params

This commit is contained in:
Alejandro Celaya
2019-01-20 22:08:32 +01:00
parent 687d8d91a9
commit 284de28f76
3 changed files with 20 additions and 25 deletions

View File

@@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
use Psr\Container\ContainerInterface;
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
use Symfony\Component\Process\Process;
use Zend\ServiceManager\ServiceManager;
// Create an empty .env file
if (! file_exists('.env')) {
@@ -15,19 +15,12 @@ if (file_exists($shlinkDbPath)) {
unlink($shlinkDbPath);
}
/** @var ServiceManager $sm */
$sm = require __DIR__ . '/config/container.php';
$sm->setAllowOverride(true);
$config = $sm->get('config');
$config['entity_manager']['connection'] = [
'driver' => 'pdo_sqlite',
'path' => $shlinkDbPath,
];
$sm->setService('config', $config);
/** @var ContainerInterface $container */
$container = require __DIR__ . '/config/test-container.php';
// Create database
$process = new Process(['vendor/bin/doctrine', 'orm:schema-tool:create', '--no-interaction', '-q', '--test'], __DIR__);
$process->inheritEnvironmentVariables()
->mustRun();
DatabaseTestCase::$em = $sm->get('em');
DatabaseTestCase::$em = $container->get('em');