2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
2021-12-01 22:45:39 -08:00
|
|
|
|
2021-11-30 20:09:29 -08:00
|
|
|
namespace Tests;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2023-03-02 13:12:25 -08:00
|
|
|
use App\Http\Middleware\SecurityHeaders;
|
2023-03-07 16:57:55 -08:00
|
|
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
2021-12-01 22:45:39 -08:00
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
2023-07-11 12:14:42 -07:00
|
|
|
use RuntimeException;
|
2023-06-22 14:41:56 -07:00
|
|
|
use Tests\Support\CustomTestMacros;
|
2023-06-22 17:37:30 -07:00
|
|
|
use Tests\Support\InteractsWithAuthentication;
|
2023-04-12 17:28:47 -07:00
|
|
|
use Tests\Support\InteractsWithSettings;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2021-12-01 22:45:39 -08:00
|
|
|
abstract class TestCase extends BaseTestCase
|
2021-11-30 20:09:29 -08:00
|
|
|
{
|
2021-12-01 22:45:39 -08:00
|
|
|
use CreatesApplication;
|
2023-06-22 14:41:56 -07:00
|
|
|
use CustomTestMacros;
|
2023-06-22 17:37:30 -07:00
|
|
|
use InteractsWithAuthentication;
|
2023-03-07 16:57:55 -08:00
|
|
|
use LazilyRefreshDatabase;
|
2023-02-02 17:41:32 -08:00
|
|
|
|
2023-03-02 13:12:25 -08:00
|
|
|
private array $globallyDisabledMiddleware = [
|
|
|
|
SecurityHeaders::class,
|
|
|
|
];
|
|
|
|
|
2023-02-02 17:41:32 -08:00
|
|
|
protected function setUp(): void
|
|
|
|
{
|
2023-07-11 12:14:42 -07:00
|
|
|
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();
|
|
|
|
|
2023-03-02 13:12:25 -08:00
|
|
|
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
2023-04-06 17:27:18 -07:00
|
|
|
|
2023-04-13 16:52:20 -07:00
|
|
|
if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) {
|
2023-05-01 16:06:28 -07:00
|
|
|
$this->initializeSettings();
|
2023-04-12 17:28:47 -07:00
|
|
|
}
|
2023-06-22 14:41:56 -07:00
|
|
|
|
|
|
|
$this->registerCustomMacros();
|
2023-02-02 17:41:32 -08:00
|
|
|
}
|
2021-12-01 22:45:39 -08:00
|
|
|
}
|