Skip to content

Commit 4f4d556

Browse files
[12.x] Add assertRedirectBackWithErrors to TestResponse (#55987)
* Add assertRedirectBackWithErrors to TestResponse * wip * wip * wip * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent feccc98 commit 4f4d556

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Illuminate/Testing/TestResponse.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,37 @@ public function assertRedirectBack()
245245
return $this;
246246
}
247247

248+
/**
249+
* Assert whether the response is redirecting back to the previous location and the session has the given errors.
250+
*
251+
* @param string|array $keys
252+
* @param mixed $format
253+
* @param string $errorBag
254+
* @return $this
255+
*/
256+
public function assertRedirectBackWithErrors($keys = [], $format = null, $errorBag = 'default')
257+
{
258+
$this->assertRedirectBack();
259+
260+
$this->assertSessionHasErrors($keys, $format, $errorBag);
261+
262+
return $this;
263+
}
264+
265+
/**
266+
* Assert whether the response is redirecting back to the previous location with no errors in the session.
267+
*
268+
* @return $this
269+
*/
270+
public function assertRedirectBackWithoutErrors()
271+
{
272+
$this->assertRedirectBack();
273+
274+
$this->assertSessionHasNoErrors();
275+
276+
return $this;
277+
}
278+
248279
/**
249280
* Assert whether the response is redirecting to a given route.
250281
*

0 commit comments

Comments
 (0)