diff --git a/src/Illuminate/Foundation/Testing/TestResponse.php b/src/Illuminate/Foundation/Testing/TestResponse.php index 36a1c12be06a..9969574e2141 100644 --- a/src/Illuminate/Foundation/Testing/TestResponse.php +++ b/src/Illuminate/Foundation/Testing/TestResponse.php @@ -883,13 +883,14 @@ public function assertSessionHasErrors($keys = [], $format = null, $errorBag = ' } /** - * Assert that the session has no errors. + * Assert that the session is missing the given errors. * * @param string|array $keys + * @param string $format * @param string $errorBag * @return $this */ - public function assertSessionHasNoErrors($keys = [], $errorBag = 'default') + public function assertSessionDoesntHaveErrors($keys = [], $format = null, $errorBag = 'default') { $keys = (array) $keys; @@ -899,13 +900,29 @@ public function assertSessionHasNoErrors($keys = [], $errorBag = 'default') $errors = $this->session()->get('errors')->getBag($errorBag); - foreach ($keys as $key) { - PHPUnit::assertFalse($errors->has($key), "Session has an unexpected error: $key"); + foreach ($keys as $key => $value) { + if (is_int($key)) { + PHPUnit::assertFalse($errors->has($value), "Session has unexpected error: $value"); + } else { + PHPUnit::assertNotContains($value, $errors->get($key, $format)); + } } return $this; } + /** + * Assert that the session has no errors. + * + * @return $this + */ + public function assertSessionHasNoErrors() + { + return $this->assertSessionMissing('errors'); + + return $this; + } + /** * Assert that the session has the given errors. *