Skip to content
Permalink
Browse files

Add withVary() and incomplete tests for other methods.

  • Loading branch information...
markstory committed Dec 2, 2016
1 parent 6eb08ce commit 7cff856c4c3807029235df7eebd7dcd405f4acb1
Showing with 75 additions and 0 deletions.
  1. +17 −0 src/Network/Response.php
  2. +58 −0 tests/TestCase/Network/ResponseTest.php
@@ -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)
{
@@ -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
@@ -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
*
@@ -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
*
@@ -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
*
@@ -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
*
@@ -951,6 +999,16 @@ public function testNotModified()
$this->assertEquals(304, $response->statusCode());
}
/**
* Tests withNotModified()
*
* @return void
*/
public function testWithNotModified()
{
$this->markTestIncomplete();
}
/**
* Test checkNotModified method
*

0 comments on commit 7cff856

Please sign in to comment.
You can’t perform that action at this time.