Files
WMS/tests/TestCase.php
T
2026-06-10 13:10:09 +01:00

45 lines
1.2 KiB
PHP

<?php
namespace Tests;
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Laravel\Fortify\Features;
abstract class TestCase extends BaseTestCase
{
protected function setUp(): void
{
parent::setUp();
config([
'app.debug' => false,
'session.driver' => 'array',
'cache.default' => 'array',
'mail.default' => 'array',
]);
$this->withoutMiddleware(ValidateCsrfToken::class);
}
/**
* POST with a real CSRF token for Fortify/web form tests.
*
* @param array<string, mixed> $data
*/
protected function csrfPost(string $uri, array $data = []): \Illuminate\Testing\TestResponse
{
$token = 'test-csrf-token';
return $this->withSession(['_token' => $token])
->post($uri, ['_token' => $token, ...$data]);
}
protected function skipUnlessFortifyHas(string $feature, ?string $message = null): void
{
if (! Features::enabled($feature)) {
$this->markTestSkipped($message ?? "Fortify feature [{$feature}] is not enabled.");
}
}
}