@@ -75,76 +75,31 @@ public function test_validation_errors_are_not_registered_when_already_registere
75
75
$ this ->assertSame ('This is a validation error ' , Inertia::getShared ('errors ' ));
76
76
}
77
77
78
- public function basicValidationErrorsProvider ()
78
+ public function test_validation_errors_are_returned_in_the_correct_format ()
79
79
{
80
- $ array = [
80
+ Session:: put ( ' errors ' , ( new ViewErrorBag ())-> put ( ' default ' , new MessageBag ( [
81
81
'name ' => 'The name field is required. ' ,
82
- 'email ' => [
83
- 'The email must be a valid email address. ' ,
84
- ],
85
- ];
86
-
87
- $ messageBag = new MessageBag ([
88
- 'name ' => 'The name field is required. ' ,
89
- 'email ' => 'The email must be a valid email address. ' ,
90
- ]);
91
-
92
- $ viewErrorBag = (new ViewErrorBag ())->put ('default ' , new MessageBag ([
93
- 'name ' => [
94
- 'The name field is required. ' ,
95
- ],
96
- 'email ' => 'The email must be a valid email address. ' ,
97
- ]));
98
-
99
- return [
100
- [$ array ],
101
- [$ messageBag ],
102
- [$ viewErrorBag ],
103
- ];
104
- }
105
-
106
- /**
107
- * @dataProvider basicValidationErrorsProvider
108
- */
109
- public function test_validation_errors_are_returned_in_the_correct_format ($ errors )
110
- {
111
- Session::put ('errors ' , $ errors );
82
+ 'email ' => 'Not a valid email address. ' ,
83
+ ])));
112
84
113
85
$ errors = Inertia::getShared ('errors ' )();
114
86
115
87
$ this ->assertIsObject ($ errors );
116
88
$ this ->assertSame ('The name field is required. ' , $ errors ->name );
117
- $ this ->assertSame ('The email must be a valid email address. ' , $ errors ->email );
89
+ $ this ->assertSame ('Not a valid email address. ' , $ errors ->email );
118
90
}
119
91
120
- public function test_validation_errors_can_have_multiple_error_bags ()
92
+ public function test_validation_errors_with_named_error_bags_are_scoped ()
121
93
{
122
- Session::put ('errors ' , tap (new ViewErrorBag (), function ($ errorBag ) {
123
- $ errorBag ->put ('default ' , new MessageBag ([
124
- 'name ' => 'The name field is required. ' ,
125
- 'email ' => 'The email must be a valid email address. ' ,
126
- ]));
127
- $ errorBag ->put ('example ' , new MessageBag ([
128
- 'name ' => 'The name field is required. ' ,
129
- 'email ' => [
130
- 'The email must be a valid email address. ' ,
131
- ],
132
- ]));
133
- }));
134
-
135
- $ errors = Inertia::getShared ('errors ' )();
136
-
137
- $ this ->assertIsObject ($ errors );
138
- $ this ->assertSame ('The name field is required. ' , $ errors ->default ['name ' ]);
139
- $ this ->assertSame ('The email must be a valid email address. ' , $ errors ->example ['email ' ]);
140
- }
94
+ Session::put ('errors ' , (new ViewErrorBag ())->put ('example ' , new MessageBag ([
95
+ 'name ' => 'The name field is required. ' ,
96
+ 'email ' => 'Not a valid email address. ' ,
97
+ ])));
141
98
142
- public function test_validation_errors_will_be_empty_when_an_invalid_value_was_set_to_the_session ()
143
- {
144
- Session::put ('errors ' , new Request ());
145
99
$ errors = Inertia::getShared ('errors ' )();
146
100
147
101
$ this ->assertIsObject ($ errors );
148
- $ this ->assertEmpty (get_object_vars ($ errors ));
102
+ $ this ->assertSame ('The name field is required. ' , $ errors ->example ->name );
103
+ $ this ->assertSame ('Not a valid email address. ' , $ errors ->example ->email );
149
104
}
150
105
}
0 commit comments