1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 18:42:31 +01:00
Pterodactyl-Panel/bootstrap/tests.php

48 lines
1.5 KiB
PHP
Raw Normal View History

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