Skip to content

Commit 19b0abf

Browse files
authored
[9.x] Add tests for assertSessionHasErrors in TestResponse (#41604)
1 parent 1744759 commit 19b0abf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Testing/TestResponseTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,23 @@ public function testGetDecryptedCookie()
16521652
$this->assertSame('cookie-value', $cookie->getValue());
16531653
}
16541654

1655+
public function testAssertSessionHasErrors()
1656+
{
1657+
app()->instance('session.store', $store = new Store('test-session', new ArraySessionHandler(1)));
1658+
1659+
$store->put('errors', $errorBag = new ViewErrorBag);
1660+
1661+
$errorBag->put('default', new MessageBag([
1662+
'foo' => [
1663+
'foo is required',
1664+
],
1665+
]));
1666+
1667+
$response = TestResponse::fromBaseResponse(new Response());
1668+
1669+
$response->assertSessionHasErrors(['foo']);
1670+
}
1671+
16551672
public function testGetEncryptedCookie()
16561673
{
16571674
$container = Container::getInstance();

0 commit comments

Comments
 (0)