snipe-it/tests/TestCase.php

51 lines
1.3 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;
2024-03-14 12:56:49 -07:00
use Tests\Support\AssertsAgainstSlackNotifications;
2024-04-22 10:32:37 -07:00
use Tests\Support\CanSkipTests;
use Tests\Support\CustomTestMacros;
use Tests\Support\InteractsWithAuthentication;
2024-03-14 15:06:52 -07:00
use Tests\Support\InitializesSettings;
2016-03-25 01:18:05 -07:00
abstract class TestCase extends BaseTestCase
{
2024-03-14 12:56:49 -07:00
use AssertsAgainstSlackNotifications;
2024-04-22 10:32:37 -07:00
use CanSkipTests;
use CreatesApplication;
use CustomTestMacros;
use InteractsWithAuthentication;
2024-03-14 15:06:52 -07:00
use InitializesSettings;
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
{
2024-03-14 16:33:49 -07:00
$this->guardAgainstMissingEnv();
2023-02-02 17:41:32 -08:00
parent::setUp();
2024-03-14 16:26:27 -07:00
$this->registerCustomMacros();
$this->withoutMiddleware($this->globallyDisabledMiddleware);
2024-03-14 15:06:52 -07:00
$this->initializeSettings();
2023-02-02 17:41:32 -08:00
}
2024-03-14 16:33:49 -07:00
private function guardAgainstMissingEnv(): void
{
if (!file_exists(realpath(__DIR__ . '/../') . '/.env.testing')) {
throw new RuntimeException(
'.env.testing file does not exist. Aborting to avoid wiping your local database.'
);
}
}
}