From 3005706abb411d1468adbff6627ff26351afe446 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 8 Oct 2018 15:33:56 -0500 Subject: [PATCH] formatting. add new method --- .../Foundation/Testing/TestResponse.php | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) 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. *