mirror of
https://github.com/wallabag/wallabag.git
synced 2026-03-21 11:32:35 +01:00
Following the phpunit/phpunit recipe for symfony/dotenv integration: wire Dotenv::bootEnv() into the test bootstrap so that .env and .env.test files are loaded before any test runs, and add force="true" to the APP_ENV and APP_DEBUG server entries so they always override any value the caller may have set in the process environment.
75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
|
|
use Symfony\Component\Dotenv\Dotenv;
|
|
use Symfony\Component\Filesystem\Filesystem;
|
|
use Symfony\Component\Process\Process;
|
|
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
|
|
if (method_exists(Dotenv::class, 'bootEnv')) {
|
|
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
|
|
}
|
|
|
|
if ('unit' === getCurrentTestSuite()) {
|
|
return;
|
|
}
|
|
|
|
(new Filesystem())->remove(__DIR__ . '/../var/cache/test');
|
|
|
|
if (!isPartialRun()) {
|
|
(new Process([
|
|
'php',
|
|
__DIR__ . '/../bin/console',
|
|
'doctrine:database:drop',
|
|
'--force',
|
|
'--env=test',
|
|
'--no-debug',
|
|
]))->run(static function ($type, $buffer): void {
|
|
echo $buffer;
|
|
});
|
|
|
|
(new Process([
|
|
'php',
|
|
__DIR__ . '/../bin/console',
|
|
'doctrine:database:create',
|
|
'--env=test',
|
|
'--no-debug',
|
|
]))->mustRun(static function ($type, $buffer): void {
|
|
echo $buffer;
|
|
});
|
|
|
|
(new Process([
|
|
'php',
|
|
__DIR__ . '/../bin/console',
|
|
'doctrine:migrations:migrate',
|
|
'--no-interaction',
|
|
'--env=test',
|
|
'--no-debug',
|
|
'-vv',
|
|
]))->mustRun(static function ($type, $buffer): void {
|
|
echo $buffer;
|
|
});
|
|
|
|
(new Process([
|
|
'php',
|
|
__DIR__ . '/../bin/console',
|
|
'doctrine:schema:validate',
|
|
'--no-interaction',
|
|
'--env=test',
|
|
'-v',
|
|
]))->mustRun(static function ($type, $buffer): void {
|
|
echo $buffer;
|
|
});
|
|
}
|
|
|
|
(new Process([
|
|
'php',
|
|
__DIR__ . '/../bin/console',
|
|
'doctrine:fixtures:load',
|
|
'--no-interaction',
|
|
'--env=test',
|
|
'--no-debug',
|
|
]))->mustRun(static function ($type, $buffer): void {
|
|
echo $buffer;
|
|
});
|