Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/bootstrap/tests.php
7432 views
1
<?php
2
3
use Illuminate\Support\Str;
4
use NunoMaduro\Collision\Provider;
5
use Illuminate\Contracts\Console\Kernel;
6
use Symfony\Component\Console\Output\ConsoleOutput;
7
8
require __DIR__ . '/../vendor/autoload.php';
9
10
$app = require __DIR__ . '/app.php';
11
12
/** @var Pterodactyl\Console\Kernel $kernel */
13
$kernel = $app->make(Kernel::class);
14
15
/*
16
* Bootstrap the kernel and prepare application for testing.
17
*/
18
$kernel->bootstrap();
19
20
// Register the collision service provider so that errors during the test
21
// setup process are output nicely.
22
(new Provider())->register();
23
24
$output = new ConsoleOutput();
25
26
$prefix = 'database.connections.' . config('database.default');
27
if (!Str::contains(config("$prefix.database"), 'test')) {
28
$output->writeln(PHP_EOL . '<error>Cannot run test process against non-testing database.</error>');
29
$output->writeln(PHP_EOL . '<error>Environment is currently pointed at: "' . config("$prefix.database") . '".</error>');
30
exit(1);
31
}
32
33
/*
34
* Perform database migrations and reseeding before continuing with
35
* running the tests.
36
*/
37
if (!env('SKIP_MIGRATIONS')) {
38
$output->writeln(PHP_EOL . '<info>Refreshing database for Integration tests...</info>');
39
$kernel->call('migrate:fresh');
40
41
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
42
$kernel->call('db:seed');
43
} else {
44
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
45
}
46
47