Files
wallabag-mirror/tests/bootstrap.php
Yassine Guedidi 65df492150 Adapt phpunit.xml.dist and tests/bootstrap.php to the phpunit/phpunit recipe
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.
2026-03-19 10:31:44 +01:00

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;
});