Skip to content

Commit

Permalink
Improve session errors assertions (#23055)
Browse files Browse the repository at this point in the history
In the previous implementation of `TestResponse::assertSessionHasErrors` i
found that was not possible to find errors that had an integer key.

This was happening because if the assertion detected that the key was an
integer, it was sending the error value to the `MessageBag::has` method,
which was incorrect because that method uses the key to determine if
there is any messages for it.
  • Loading branch information
roberto-aguilar authored and taylorotwell committed Feb 7, 2018
1 parent 8135cf5 commit 4fbb54b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ public function assertSessionHasErrors($keys = [], $format = null, $errorBag = '
$errors = app('session.store')->get('errors')->getBag($errorBag);

foreach ($keys as $key => $value) {
if (is_int($key)) {
PHPUnit::assertTrue($errors->has($value), "Session missing error: $value");
if (is_array($value)) {
PHPUnit::assertArraySubset($value, $errors->get($key, $format));
} else {
PHPUnit::assertContains($value, $errors->get($key, $format));
}
Expand Down

0 comments on commit 4fbb54b

Please sign in to comment.