forked from kubectyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.php
45 lines (35 loc) · 1.41 KB
/
tests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
use Illuminate\Support\Str;
use NunoMaduro\Collision\Provider;
use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Output\ConsoleOutput;
require __DIR__ . '/../vendor/autoload.php';
$app = require __DIR__ . '/app.php';
/** @var \Kubectyl\Console\Kernel $kernel */
$kernel = $app->make(Kernel::class);
/*
* 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.
(new Provider())->register();
$output = new ConsoleOutput();
$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>');
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');
$output->writeln('<info>Seeding database for Integration tests...</info>' . PHP_EOL);
$kernel->call('db:seed');
} else {
$output->writeln(PHP_EOL . '<comment>Skipping database migrations...</comment>' . PHP_EOL);
}