Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add withVary() and incomplete tests for other methods.
  • Loading branch information
markstory committed Dec 2, 2016
1 parent 6eb08ce commit 7cff856
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Network/Response.php
Expand Up @@ -1440,6 +1440,7 @@ public function notModified()
* @param string|array|null $cacheVariances A single Vary string or an array
* containing the list for variances.
* @return array|null
* @deprecated 3.4.0 Use withVary() instead.
*/
public function vary($cacheVariances = null)
{
Expand All @@ -1455,6 +1456,22 @@ public function vary($cacheVariances = null)
return null;
}

/**
* Create a new instance with the Vary header set.
*
* If an array is passed values will be imploded into a comma
* separated string. If no parameters are passed, then an
* array with the current Vary header value is returned
*
* @param string|array $cacheVariances A single Vary string or an array
* containing the list for variances.
* @return static
*/
public function withVary($cacheVariances)
{
return $this->withHeader('Vary', (array) $cacheVariances);
}

/**
* Sets the response Etag, Etags are a strong indicative that a response
* can be cached by a HTTP client. A bad way of generating Etags is
Expand Down
58 changes: 58 additions & 0 deletions tests/TestCase/Network/ResponseTest.php
Expand Up @@ -831,6 +831,16 @@ public function testSharable()
$this->assertEquals('private, max-age=3600', $response->getHeaderLine('Cache-Control'));
}

/**
* Tests withSharable()
*
* @return void
*/
public function testWithSharable()
{
$this->markTestIncomplete();
}

/**
* Tests setting of max-age Cache-Control directive
*
Expand All @@ -850,6 +860,16 @@ public function testMaxAge()
$this->assertEquals('max-age=3600, private', $response->getHeaderLine('Cache-Control'));
}

/**
* Tests withMaxAge()
*
* @return void
*/
public function testWithMaxAge()
{
$this->markTestIncomplete();
}

/**
* Tests setting of s-maxage Cache-Control directive
*
Expand Down Expand Up @@ -912,6 +932,24 @@ public function testVary()
$this->assertEquals('Accept-language, Accept-encoding', $response->getHeaderLine('vary'));
}

/**
* Tests withVary()
*
* @return void
*/
public function testWithVary()
{
$response = new Response();
$new = $response->withVary('Accept-encoding');

$this->assertFalse($response->hasHeader('Vary'));
$this->assertEquals('Accept-encoding', $new->getHeaderLine('Vary'));

$new = $response->withVary(['Accept-encoding', 'Accept-language']);
$this->assertFalse($response->hasHeader('Vary'));
$this->assertEquals('Accept-encoding,Accept-language', $new->getHeaderLine('Vary'));
}

/**
* Tests getting/setting the Etag header
*
Expand All @@ -930,6 +968,16 @@ public function testEtag()
$this->assertEquals('W/"something"', $response->getHeaderLine('Etag'));
}

/**
* Tests withEtag()
*
* @return void
*/
public function testWithEtag()
{
$this->markTestIncomplete();
}

/**
* Tests that the response is able to be marked as not modified
*
Expand All @@ -951,6 +999,16 @@ public function testNotModified()
$this->assertEquals(304, $response->statusCode());
}

/**
* Tests withNotModified()
*
* @return void
*/
public function testWithNotModified()
{
$this->markTestIncomplete();
}

/**
* Test checkNotModified method
*
Expand Down

0 comments on commit 7cff856

Please sign in to comment.