Skip to content

Commit 20bc4da

Browse files
derekmdtaylorotwell
authored andcommitted
Fix assertCookie() when unserialized (#25149)
EncryptCookies middleware now has `$serialize = false` OOTB so cookie assertions in tests now fail.
1 parent 5a38cb1 commit 20bc4da

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Illuminate/Foundation/Testing/TestResponse.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,12 @@ public function assertLocation($uri)
206206
*
207207
* @param string $cookieName
208208
* @param mixed $value
209+
* @param bool $unserialize
209210
* @return $this
210211
*/
211-
public function assertPlainCookie($cookieName, $value = null)
212+
public function assertPlainCookie($cookieName, $value = null, $unserialize = false)
212213
{
213-
$this->assertCookie($cookieName, $value, false);
214+
$this->assertCookie($cookieName, $value, false, $unserialize);
214215

215216
return $this;
216217
}
@@ -221,9 +222,10 @@ public function assertPlainCookie($cookieName, $value = null)
221222
* @param string $cookieName
222223
* @param mixed $value
223224
* @param bool $encrypted
225+
* @param bool $unserialize
224226
* @return $this
225227
*/
226-
public function assertCookie($cookieName, $value = null, $encrypted = true)
228+
public function assertCookie($cookieName, $value = null, $encrypted = true, $unserialize = false)
227229
{
228230
PHPUnit::assertNotNull(
229231
$cookie = $this->getCookie($cookieName),
@@ -237,7 +239,7 @@ public function assertCookie($cookieName, $value = null, $encrypted = true)
237239
$cookieValue = $cookie->getValue();
238240

239241
$actual = $encrypted
240-
? app('encrypter')->decrypt($cookieValue) : $cookieValue;
242+
? app('encrypter')->decrypt($cookieValue, $unserialize) : $cookieValue;
241243

242244
PHPUnit::assertEquals(
243245
$value, $actual,

0 commit comments

Comments
 (0)