mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 00:47:25 -06:00
Updated structure for tests config files
This commit is contained in:
parent
e7c5cf0846
commit
87ba7a7179
2
build.sh
2
build.sh
@ -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}"
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
12
config/test/swoole.global.php
Normal file
12
config/test/swoole.global.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
|
||||
'zend-expressive-swoole' => [
|
||||
'swoole-http-server' => [
|
||||
'port' => 9999,
|
||||
],
|
||||
],
|
||||
|
||||
];
|
10
module/Common/test-db/ApiTest/ApiTestCase.php
Normal file
10
module/Common/test-db/ApiTest/ApiTestCase.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\ApiTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class ApiTestCase extends TestCase
|
||||
{
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<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">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
|
||||
bootstrap="./config/test/bootstrap_db_tests.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Shlink database tests">
|
||||
<directory>./module/*/test-db</directory>
|
||||
|
Loading…
Reference in New Issue
Block a user