1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 18:42:31 +01:00
Pterodactyl-Panel/bootstrap/tests.php
Dane Everitt 2ed3763d21
cs fix
2020-06-28 15:43:44 -07:00

39 lines
1.2 KiB
PHP

<?php
use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Output\ConsoleOutput;
require __DIR__ . '/../vendor/autoload.php';
$app = require __DIR__ . '/app.php';
/** @var \Pterodactyl\Console\Kernel $kernel */
$kernel = $app->make(Kernel::class);
/*
* Bootstrap the kernel and prepare application for testing.
*/
$kernel->bootstrap();
$output = new ConsoleOutput;
if (config('database.default') !== 'testing') {
$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('database.default') . '".</error>');
exit(1);
}
/*
* Perform database migrations and reseeding before continuing with
* running the tests.
*/
if (! env('SKIP_MIGRATIONS')) {
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
$kernel->call('migrate:fresh', ['--database' => 'testing']);
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
$kernel->call('db:seed', ['--database' => 'testing']);
} else {
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
}