Skip to content

Commit

Permalink
Add test for #45
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinrob committed Feb 27, 2016
1 parent 7077ca3 commit 5e003c1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5e003c1

Please sign in to comment.