Files
pterodactyl-panel/bootstrap/tests.php
T

47 lines
1.4 KiB
PHP
Raw Normal View History

2018-03-04 16:30:16 -06:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2018-03-04 16:30:16 -06:00
use Illuminate\Contracts\Console\Kernel;
2026-10-05 18:10:18 -04:00
use Illuminate\Support\Str;
2018-03-04 16:30:16 -06:00
use Symfony\Component\Console\Output\ConsoleOutput;
2026-10-05 18:10:18 -04:00
require __DIR__.'/../vendor/autoload.php';
2018-03-04 16:30:16 -06:00
2026-10-05 18:10:18 -04:00
$app = require __DIR__.'/app.php';
2018-03-04 16:30:16 -06:00
$kernel = $app->make(Kernel::class);
2018-04-08 16:37:27 -04:00
/*
2018-03-04 16:30:16 -06:00
* Bootstrap the kernel and prepare application for testing.
*/
$kernel->bootstrap();
2026-10-05 18:10:18 -04:00
$output = new ConsoleOutput;
2021-01-23 12:09:16 -08:00
2026-10-05 18:10:18 -04:00
$prefix = 'database.connections.'.config('database.default');
if (! Str::contains(config("$prefix.database"), 'test')) {
$output->writeln(PHP_EOL.'<error>Cannot run test process against non-testing database.</error>');
$output->writeln(PHP_EOL.'<error>Environment is currently pointed at: "'.config("$prefix.database").'".</error>');
2020-06-25 21:21:05 -07:00
exit(1);
}
2018-04-08 16:37:27 -04:00
/*
2018-03-04 16:30:16 -06:00
* Perform database migrations and reseeding before continuing with
* running the tests.
*/
2026-10-05 18:10:18 -04:00
if (! env('SKIP_MIGRATIONS')) {
$output->writeln(PHP_EOL.'<info>Refreshing database for Integration tests...</info>');
$kernel->call('migrate:fresh');
2020-06-25 21:21:05 -07:00
2026-10-05 18:10:18 -04:00
$output->writeln('<info>Seeding database for Integration tests...</info>'.PHP_EOL);
$kernel->call('db:seed');
2020-06-25 21:21:05 -07:00
} else {
2026-10-05 18:10:18 -04:00
$output->writeln(PHP_EOL.'<comment>Skipping database migrations...</comment>'.PHP_EOL);
2020-06-25 21:21:05 -07:00
}
2026-10-05 18:10:18 -04:00
// Pop the error and exception handlers the bootstrap-level application installed so
// PHPUnit starts from a clean handler baseline; each test boots its own application.
restore_error_handler();
restore_exception_handler();