|
5 | 5 | use Illuminate\Session\Middleware\StartSession;
|
6 | 6 | use Illuminate\Support\Facades\Config;
|
7 | 7 | use Illuminate\Support\Facades\Route;
|
| 8 | +use Inertia\EncryptHistoryMiddleware; |
8 | 9 | use Inertia\Inertia;
|
9 | 10 | use Inertia\Tests\Stubs\ExampleMiddleware;
|
10 | 11 |
|
@@ -47,6 +48,40 @@ public function test_the_history_can_be_encrypted(): void
|
47 | 48 | ]);
|
48 | 49 | }
|
49 | 50 |
|
| 51 | + public function test_the_history_can_be_encrypted_via_middleware(): void |
| 52 | + { |
| 53 | + Route::middleware([StartSession::class, ExampleMiddleware::class, EncryptHistoryMiddleware::class])->get('/', function () { |
| 54 | + return Inertia::render('User/Edit'); |
| 55 | + }); |
| 56 | + |
| 57 | + $response = $this->withoutExceptionHandling()->get('/', [ |
| 58 | + 'X-Inertia' => 'true', |
| 59 | + ]); |
| 60 | + |
| 61 | + $response->assertSuccessful(); |
| 62 | + $response->assertJson([ |
| 63 | + 'component' => 'User/Edit', |
| 64 | + 'encryptHistory' => true, |
| 65 | + ]); |
| 66 | + } |
| 67 | + |
| 68 | + public function test_the_history_can_be_encrypted_via_middleware_alias(): void |
| 69 | + { |
| 70 | + Route::middleware([StartSession::class, ExampleMiddleware::class, 'inertia.encrypt'])->get('/', function () { |
| 71 | + return Inertia::render('User/Edit'); |
| 72 | + }); |
| 73 | + |
| 74 | + $response = $this->withoutExceptionHandling()->get('/', [ |
| 75 | + 'X-Inertia' => 'true', |
| 76 | + ]); |
| 77 | + |
| 78 | + $response->assertSuccessful(); |
| 79 | + $response->assertJson([ |
| 80 | + 'component' => 'User/Edit', |
| 81 | + 'encryptHistory' => true, |
| 82 | + ]); |
| 83 | + } |
| 84 | + |
50 | 85 | public function test_the_history_can_be_encrypted_globally(): void
|
51 | 86 | {
|
52 | 87 | Route::middleware([StartSession::class, ExampleMiddleware::class])->get('/', function () {
|
|
0 commit comments