|
|
@@ -4,6 +4,7 @@ namespace Tests;
|
|
|
|
|
|
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
|
+use RuntimeException;
|
|
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
|
{
|
|
|
@@ -11,6 +12,21 @@ abstract class TestCase extends BaseTestCase
|
|
|
{
|
|
|
parent::setUp();
|
|
|
|
|
|
+ $this->guardAgainstProductionDatabase();
|
|
|
+
|
|
|
$this->withoutMiddleware(ValidateCsrfToken::class);
|
|
|
}
|
|
|
+
|
|
|
+ private function guardAgainstProductionDatabase(): void
|
|
|
+ {
|
|
|
+ $database = config('database.connections.'.config('database.default').'.database');
|
|
|
+
|
|
|
+ if ($database !== 'crm_testing') {
|
|
|
+ throw new RuntimeException(sprintf(
|
|
|
+ 'Refusing to run tests against database "%s". Expected "crm_testing". '.
|
|
|
+ 'Likely cause: stale bootstrap/cache/config.php. Run "php artisan config:clear".',
|
|
|
+ $database
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|