2018-03-04 22:30:16 +00:00
|
|
|
<?php
|
|
|
|
|
2021-01-23 20:09:16 +00:00
|
|
|
use NunoMaduro\Collision\Provider;
|
2018-03-04 22:30:16 +00:00
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
|
|
2018-03-22 03:28:01 +00:00
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
2018-03-04 22:30:16 +00:00
|
|
|
|
|
|
|
$app = require __DIR__ . '/app.php';
|
|
|
|
|
|
|
|
/** @var \Pterodactyl\Console\Kernel $kernel */
|
|
|
|
$kernel = $app->make(Kernel::class);
|
|
|
|
|
2018-04-08 20:37:27 +00:00
|
|
|
/*
|
2018-03-04 22:30:16 +00:00
|
|
|
* Bootstrap the kernel and prepare application for testing.
|
|
|
|
*/
|
|
|
|
$kernel->bootstrap();
|
|
|
|
|
2021-01-23 20:09:16 +00:00
|
|
|
// Register the collision service provider so that errors during the test
|
|
|
|
// setup process are output nicely.
|
2021-01-23 20:33:34 +00:00
|
|
|
(new Provider())->register();
|
2021-01-23 20:09:16 +00:00
|
|
|
|
2021-01-23 20:33:34 +00:00
|
|
|
$output = new ConsoleOutput();
|
2018-03-04 22:30:16 +00:00
|
|
|
|
2022-05-05 00:41:04 +00:00
|
|
|
$prefix = 'database.connections.' . config('database.default');
|
|
|
|
if (config("$prefix.database") !== 'panel_test') {
|
2020-06-26 04:21:05 +00:00
|
|
|
$output->writeln(PHP_EOL . '<error>Cannot run test process against non-testing database.</error>');
|
2022-05-05 00:41:04 +00:00
|
|
|
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config("$prefix.database") . '".</error>');
|
2020-06-26 04:21:05 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2018-04-08 20:37:27 +00:00
|
|
|
/*
|
2018-03-04 22:30:16 +00:00
|
|
|
* Perform database migrations and reseeding before continuing with
|
|
|
|
* running the tests.
|
|
|
|
*/
|
2021-01-23 20:33:34 +00:00
|
|
|
if (!env('SKIP_MIGRATIONS')) {
|
2020-06-26 04:21:05 +00:00
|
|
|
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
|
2022-05-05 00:41:04 +00:00
|
|
|
$kernel->call('migrate:fresh');
|
2020-06-26 04:21:05 +00:00
|
|
|
|
|
|
|
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
|
2022-05-05 00:41:04 +00:00
|
|
|
$kernel->call('db:seed');
|
2020-06-26 04:21:05 +00:00
|
|
|
} else {
|
|
|
|
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
|
|
|
|
}
|