File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,24 @@ public function test_default_validation_errors_can_be_overwritten()
140
140
]);
141
141
}
142
142
143
+ public function test_validation_errors_are_scoped_to_error_bag_header ()
144
+ {
145
+ Session::put ('errors ' , (new ViewErrorBag ())->put ('default ' , new MessageBag ([
146
+ 'name ' => 'The name field is required. ' ,
147
+ 'email ' => 'Not a valid email address. ' ,
148
+ ])));
149
+
150
+ Route::middleware ([StartSession::class, ExampleMiddleware::class])->get ('/ ' , function () {
151
+ $ errors = Inertia::getShared ('errors ' )();
152
+
153
+ $ this ->assertIsObject ($ errors );
154
+ $ this ->assertSame ('The name field is required. ' , $ errors ->example ->name );
155
+ $ this ->assertSame ('Not a valid email address. ' , $ errors ->example ->email );
156
+ });
157
+
158
+ $ this ->withoutExceptionHandling ()->get ('/ ' , ['X-Inertia-Error-Bag ' => 'example ' ]);
159
+ }
160
+
143
161
public function test_middleware_can_change_the_root_view_via_a_property ()
144
162
{
145
163
$ this ->prepareMockEndpoint (null , [], new class extends Middleware {
You can’t perform that action at this time.
0 commit comments