From 5e003c1e8bb572a41744b4f393079b1312dfbd5d Mon Sep 17 00:00:00 2001 From: Kevin Robatel Date: Sat, 27 Feb 2016 18:30:53 +0100 Subject: [PATCH] Add test for #45 --- tests/ValidationTest.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/ValidationTest.php b/tests/ValidationTest.php index 6bd59713..b6bdddcd 100644 --- a/tests/ValidationTest.php +++ b/tests/ValidationTest.php @@ -33,12 +33,17 @@ public function setUp() switch ($request->getUri()->getPath()) { case '/etag': if ($request->getHeaderLine('If-None-Match') == 'MyBeautifulHash') { - return new FulfilledPromise(new Response(304)); + return new FulfilledPromise( + (new Response(304)) + ->withHeader('X-Replaced', '2') + ); } return new FulfilledPromise( (new Response()) ->withHeader('Etag', 'MyBeautifulHash') + ->withHeader('X-Base-Info', '1') + ->withHeader('X-Replaced', '1') ); case '/etag-changed': if ($request->getHeaderLine('If-None-Match') == 'MyBeautifulHash') { @@ -83,12 +88,16 @@ public function setUp() public function testEtagHeader() { - $this->client->get('http://test.com/etag'); + $response = $this->client->get('http://test.com/etag'); + $this->assertEquals('1', $response->getHeaderLine('X-Base-Info')); + $this->assertEquals('1', $response->getHeaderLine('X-Replaced')); sleep(1); $response = $this->client->get('http://test.com/etag'); $this->assertEquals(CacheMiddleware::HEADER_CACHE_HIT, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO)); + $this->assertEquals('1', $response->getHeaderLine('X-Base-Info')); + $this->assertEquals('2', $response->getHeaderLine('X-Replaced')); } public function testEtagChangeHeader()