This repository was archived by the owner on Feb 26, 2018. It is now read-only.
File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,11 @@ public function hasError($name)
207
207
208
208
public function getErrors ()
209
209
{
210
- return $ this ->errorStore ->getErrors ();
210
+ if (! $ this ->hasErrors ()){
211
+ return null ;
212
+ }
213
+
214
+ return $ this ->errorStore ->getErrors ()->all ();
211
215
}
212
216
213
217
public function getError ($ name , $ format = null )
Original file line number Diff line number Diff line change @@ -217,11 +217,22 @@ public function testCanRetrieveErrorMessages()
217
217
{
218
218
$ errors = new MessageBag (['foo.bar ' => 'Some error ' ]);
219
219
$ errorStore = Mockery::mock ('AdamWathan\Form\ErrorStore\ErrorStoreInterface ' );
220
+ $ errorStore ->shouldReceive ('hasErrors ' )->andReturn (true );
220
221
$ errorStore ->shouldReceive ('getErrors ' )->andReturn ($ errors );
221
222
222
223
$ this ->form ->setErrorStore ($ errorStore );
223
224
224
- $ expected = $ errors ;
225
+ $ expected = $ errors ->all ();
226
+ $ result = $ this ->form ->getErrors ();
227
+ $ this ->assertEquals ($ expected , $ result );
228
+
229
+ $ errorStore = Mockery::mock ('AdamWathan\Form\ErrorStore\ErrorStoreInterface ' );
230
+ $ errorStore ->shouldReceive ('hasErrors ' )->andReturn (false );
231
+ $ errorStore ->shouldReceive ('getErrors ' )->andReturn (null );
232
+
233
+ $ this ->form ->setErrorStore ($ errorStore );
234
+
235
+ $ expected = null ;
225
236
$ result = $ this ->form ->getErrors ();
226
237
$ this ->assertEquals ($ expected , $ result );
227
238
}
You can’t perform that action at this time.
0 commit comments