inspiren-sem-tool/tests/Unit/PageExpiredResponseTest.php

24 lines
650 B
PHP

<?php
use Illuminate\Support\Facades\Route;
uses(Tests\TestCase::class);
beforeEach(function () {
Route::middleware('web')->post('/_test/page-expired', fn () => abort(419));
});
test('page expired web responses redirect back with a warning', function () {
$response = $this->from('/dashboard')->post('/_test/page-expired');
$response
->assertRedirect('/dashboard')
->assertSessionHas('message-warning', 'Your session expired. Please try again.');
});
test('page expired json responses keep the 419 status', function () {
$response = $this->postJson('/_test/page-expired');
$response->assertStatus(419);
});