32 lines
887 B
PHP
32 lines
887 B
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
use RuntimeException;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
/**
|
|
* Boot the application only when the test database is explicitly isolated.
|
|
*/
|
|
public function createApplication(): Application
|
|
{
|
|
$app = parent::createApplication();
|
|
|
|
$database = (string) $app['config']->get(
|
|
'database.connections.'.$app['config']->get('database.default').'.database'
|
|
);
|
|
|
|
if (! preg_match('/^shopit_(?:test|testing)(?:_\d+)?$/', $database)) {
|
|
throw new RuntimeException(sprintf(
|
|
'Refusing to run tests against database [%s]. Use [shopit_test] or [shopit_testing].',
|
|
$database !== '' ? $database : '(empty)'
|
|
));
|
|
}
|
|
|
|
return $app;
|
|
}
|
|
}
|