From ea4951d2f0c91bffe4125869de536e6808cbd520 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 24 Mar 2017 12:09:04 -0400 Subject: [PATCH] Add test for ignoring expired cookies. --- .../Http/Cookie/CookieCollectionTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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'); + } }