mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-26 02:40:41 -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=docs \
|
||||||
--exclude=indocker \
|
--exclude=indocker \
|
||||||
--exclude=docker* \
|
--exclude=docker* \
|
||||||
--exclude=func_tests_bootstrap.php \
|
|
||||||
--exclude=php* \
|
--exclude=php* \
|
||||||
--exclude=infection.json \
|
--exclude=infection.json \
|
||||||
--exclude=phpstan.neon \
|
--exclude=phpstan.neon \
|
||||||
--exclude=config/autoload/*local* \
|
--exclude=config/autoload/*local* \
|
||||||
|
--exclude=config/test \
|
||||||
--exclude=**/test* \
|
--exclude=**/test* \
|
||||||
--exclude=build*
|
--exclude=build*
|
||||||
cd "${builtcontent}"
|
cd "${builtcontent}"
|
||||||
|
@ -6,6 +6,7 @@ namespace Shlinkio\Shlink;
|
|||||||
use Acelaya\ExpressiveErrorHandler;
|
use Acelaya\ExpressiveErrorHandler;
|
||||||
use Zend\ConfigAggregator;
|
use Zend\ConfigAggregator;
|
||||||
use Zend\Expressive;
|
use Zend\Expressive;
|
||||||
|
use function Shlinkio\Shlink\Common\env;
|
||||||
|
|
||||||
return (new ConfigAggregator\ConfigAggregator([
|
return (new ConfigAggregator\ConfigAggregator([
|
||||||
Expressive\ConfigProvider::class,
|
Expressive\ConfigProvider::class,
|
||||||
@ -21,4 +22,7 @@ return (new ConfigAggregator\ConfigAggregator([
|
|||||||
Rest\ConfigProvider::class,
|
Rest\ConfigProvider::class,
|
||||||
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
|
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
|
||||||
new ConfigAggregator\ZendConfigProvider('config/params/{generated_config.php,*.config.{php,json}}'),
|
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();
|
], 'data/cache/app_config.php'))->getMergedConfig();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
// Create an empty .env file
|
// Create an empty .env file
|
||||||
@ -16,10 +16,10 @@ if (file_exists($shlinkDbPath)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var ContainerInterface $container */
|
/** @var ContainerInterface $container */
|
||||||
$container = require __DIR__ . '/config/test-container.php';
|
$container = require __DIR__ . '/../test-container.php';
|
||||||
|
|
||||||
// Create database
|
// 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()
|
$process->inheritEnvironmentVariables()
|
||||||
->mustRun();
|
->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
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\Common\DbUnit;
|
namespace ShlinkioTest\Shlink\Common\DbTest;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -20,14 +20,12 @@ abstract class DatabaseTestCase extends TestCase
|
|||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
// Empty all entity tables defined by this test after each test
|
|
||||||
foreach (static::ENTITIES_TO_EMPTY as $entityClass) {
|
foreach (static::ENTITIES_TO_EMPTY as $entityClass) {
|
||||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||||
$qb->delete($entityClass, 'x');
|
$qb->delete($entityClass, 'x');
|
||||||
$qb->getQuery()->execute();
|
$qb->getQuery()->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear entity manager
|
|
||||||
$this->getEntityManager()->clear();
|
$this->getEntityManager()->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,7 +11,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
|
|||||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
|
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
|
||||||
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||||
use function count;
|
use function count;
|
||||||
|
|
||||||
class ShortUrlRepositoryTest extends DatabaseTestCase
|
class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||||
|
@ -5,7 +5,7 @@ namespace ShlinkioTest\Shlink\Core\Repository;
|
|||||||
|
|
||||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||||
use Shlinkio\Shlink\Core\Repository\TagRepository;
|
use Shlinkio\Shlink\Core\Repository\TagRepository;
|
||||||
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||||
|
|
||||||
class TagRepositoryTest extends 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\Entity\VisitLocation;
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
||||||
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
use ShlinkioTest\Shlink\Common\DbTest\DatabaseTestCase;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
|
|
||||||
class VisitRepositoryTest extends DatabaseTestCase
|
class VisitRepositoryTest extends DatabaseTestCase
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
<phpunit
|
<phpunit
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
|
||||||
bootstrap="./db_tests_bootstrap.php"
|
bootstrap="./config/test/bootstrap_db_tests.php"
|
||||||
colors="true">
|
colors="true"
|
||||||
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Shlink database tests">
|
<testsuite name="Shlink database tests">
|
||||||
<directory>./module/*/test-db</directory>
|
<directory>./module/*/test-db</directory>
|
||||||
|
Loading…
Reference in New Issue
Block a user