2017-10-22 11:03:35 -05:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
|
|
|
use Symfony\Component\Process\Process;
|
|
|
|
use Zend\ServiceManager\ServiceManager;
|
|
|
|
|
|
|
|
// Create an empty .env file
|
|
|
|
if (! file_exists('.env')) {
|
|
|
|
touch('.env');
|
|
|
|
}
|
|
|
|
|
2017-10-23 05:19:28 -05:00
|
|
|
$shlinkDbPath = realpath(sys_get_temp_dir()) . '/shlink-tests.db';
|
|
|
|
if (file_exists($shlinkDbPath)) {
|
|
|
|
unlink($shlinkDbPath);
|
|
|
|
}
|
|
|
|
|
2017-10-22 11:03:35 -05:00
|
|
|
/** @var ServiceManager $sm */
|
|
|
|
$sm = require __DIR__ . '/config/container.php';
|
2017-10-23 05:19:28 -05:00
|
|
|
$sm->setAllowOverride(true);
|
|
|
|
$config = $sm->get('config');
|
|
|
|
$config['entity_manager']['connection'] = [
|
|
|
|
'driver' => 'pdo_sqlite',
|
|
|
|
'path' => $shlinkDbPath,
|
|
|
|
];
|
|
|
|
$sm->setService('config', $config);
|
2017-10-22 11:03:35 -05:00
|
|
|
|
2017-10-23 04:20:55 -05:00
|
|
|
// Create database
|
|
|
|
$process = new Process('vendor/bin/doctrine orm:schema-tool:create --no-interaction -q --test', __DIR__);
|
2017-10-22 11:03:35 -05:00
|
|
|
$process->inheritEnvironmentVariables()
|
|
|
|
->mustRun();
|
|
|
|
|
2017-10-23 04:20:55 -05:00
|
|
|
DatabaseTestCase::$em = $sm->get('em');
|