snipe-it/tests/TestCase.php

43 lines
1.1 KiB
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
namespace Tests;
use App\Http\Middleware\SecurityHeaders;
2023-03-07 16:57:55 -08:00
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use RuntimeException;
use Tests\Support\CustomTestMacros;
use Tests\Support\InteractsWithAuthentication;
use Tests\Support\InteractsWithSettings;
2016-03-25 01:18:05 -07:00
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use CustomTestMacros;
use InteractsWithAuthentication;
2023-03-07 16:57:55 -08:00
use LazilyRefreshDatabase;
2023-02-02 17:41:32 -08:00
private array $globallyDisabledMiddleware = [
SecurityHeaders::class,
];
2023-02-02 17:41:32 -08:00
protected function setUp(): void
{
if (!file_exists(realpath(__DIR__ . '/../') . '/.env.testing')) {
throw new RuntimeException(
'.env.testing file does not exist. Aborting to avoid wiping your local database'
);
}
2023-02-02 17:41:32 -08:00
parent::setUp();
$this->withoutMiddleware($this->globallyDisabledMiddleware);
if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) {
2023-05-01 16:06:28 -07:00
$this->initializeSettings();
}
$this->registerCustomMacros();
2023-02-02 17:41:32 -08:00
}
}