Skip to content

Commit

Permalink
formatting. add new method
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 8, 2018
1 parent 5e7832c commit 3005706
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
*
Expand Down

0 comments on commit 3005706

Please sign in to comment.