Updated structure for tests config files

This commit is contained in:
Alejandro Celaya 2019-01-26 09:09:49 +01:00
parent e7c5cf0846
commit 87ba7a7179
10 changed files with 39 additions and 14 deletions

View File

@ -28,11 +28,11 @@ rsync -av * "${builtcontent}" \
--exclude=docs \
--exclude=indocker \
--exclude=docker* \
--exclude=func_tests_bootstrap.php \
--exclude=php* \
--exclude=infection.json \
--exclude=phpstan.neon \
--exclude=config/autoload/*local* \
--exclude=config/test \
--exclude=**/test* \
--exclude=build*
cd "${builtcontent}"

View File

@ -6,6 +6,7 @@ namespace Shlinkio\Shlink;
use Acelaya\ExpressiveErrorHandler;
use Zend\ConfigAggregator;
use Zend\Expressive;
use function Shlinkio\Shlink\Common\env;
return (new ConfigAggregator\ConfigAggregator([
Expressive\ConfigProvider::class,
@ -21,4 +22,7 @@ return (new ConfigAggregator\ConfigAggregator([
Rest\ConfigProvider::class,
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
new ConfigAggregator\ZendConfigProvider('config/params/{generated_config.php,*.config.{php,json}}'),
env('APP_ENV') === 'test'
? new ConfigAggregator\PhpFileProvider('config/test/*.global.php')
: new ConfigAggregator\ArrayProvider([]),
], 'data/cache/app_config.php'))->getMergedConfig();

View File

@ -2,7 +2,7 @@
declare(strict_types=1);
use Psr\Container\ContainerInterface;
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
use Symfony\Component\Process\Process;
// Create an empty .env file
@ -16,10 +16,10 @@ if (file_exists($shlinkDbPath)) {
}
/** @var ContainerInterface $container */
$container = require __DIR__ . '/config/test-container.php';
$container = require __DIR__ . '/../test-container.php';
// Create database
$process = new Process(['vendor/bin/doctrine', 'orm:schema-tool:create', '--no-interaction', '-q', '--test'], __DIR__);
$process = new Process(['vendor/bin/doctrine', 'orm:schema-tool:create', '--no-interaction', '-q', '--test']);
$process->inheritEnvironmentVariables()
->mustRun();

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
return [
'zend-expressive-swoole' => [
'swoole-http-server' => [
'port' => 9999,
],
],
];

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\ApiTest;
use PHPUnit\Framework\TestCase;
abstract class ApiTestCase extends TestCase
{
}

View File

@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\DbUnit;
namespace ShlinkioTest\Shlink\Common\DbTest;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
@ -20,14 +20,12 @@ abstract class DatabaseTestCase extends TestCase
public function tearDown()
{
// Empty all entity tables defined by this test after each test
foreach (static::ENTITIES_TO_EMPTY as $entityClass) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->delete($entityClass, 'x');
$qb->getQuery()->execute();
}
// Clear entity manager
$this->getEntityManager()->clear();
}
}

View File

@ -11,7 +11,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Model\Visitor;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
use function count;
class ShortUrlRepositoryTest extends DatabaseTestCase

View File

@ -5,7 +5,7 @@ namespace ShlinkioTest\Shlink\Core\Repository;
use Shlinkio\Shlink\Core\Entity\Tag;
use Shlinkio\Shlink\Core\Repository\TagRepository;
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
class TagRepositoryTest extends DatabaseTestCase
{

View File

@ -10,7 +10,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
use Shlinkio\Shlink\Core\Entity\VisitLocation;
use Shlinkio\Shlink\Core\Model\Visitor;
use Shlinkio\Shlink\Core\Repository\VisitRepository;
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
use function sprintf;
class VisitRepositoryTest extends DatabaseTestCase

View File

@ -2,8 +2,9 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
bootstrap="./db_tests_bootstrap.php"
colors="true">
bootstrap="./config/test/bootstrap_db_tests.php"
colors="true"
>
<testsuites>
<testsuite name="Shlink database tests">
<directory>./module/*/test-db</directory>