major update
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user