diff --git a/tests/TestCase/Http/Cookie/CookieCollectionTest.php b/tests/TestCase/Http/Cookie/CookieCollectionTest.php index 81a34a87cff..ab8d0122637 100644 --- a/tests/TestCase/Http/Cookie/CookieCollectionTest.php +++ b/tests/TestCase/Http/Cookie/CookieCollectionTest.php @@ -225,4 +225,22 @@ public function testAddFromResponse() 'Has expiry' ); } + + /** + * Test adding cookies from a response ignores expired cookies + * + * @return void + */ + public function testAddFromResponseIgnoreExpired() + { + $collection = new CookieCollection(); + $request = new ServerRequest([ + 'url' => '/app' + ]); + $response = (new Response()) + ->withAddedHeader('Set-Cookie', 'test=value') + ->withAddedHeader('Set-Cookie', 'expired=soon; Expires=Wed, 09-Jun-2012 10:18:14 GMT; Path=/; HttpOnly; Secure;'); + $new = $collection->addFromResponse($response, $request); + $this->assertFalse($new->has('expired'),'Should drop expired cookies'); + } }