sleep(15); // expire the cache
- $that = $this;
-
- $this->setNextResponse(304, array(), '', function (Request $request, Response $response) use ($time, $that) {
- $that->assertEquals($time->format(DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE'));
+ $this->setNextResponse(304, array(), '', function (Request $request, Response $response) use ($time) {
+ $this->assertEquals($time->format(DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE'));
});
$this->request('GET', '/');
public function testPassesHeadRequestsThroughDirectlyOnPass()
{
- $that = $this;
- $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) {
+ $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) {
$response->setContent('');
$response->setStatusCode(200);
- $that->assertEquals('HEAD', $request->getMethod());
+ $this->assertEquals('HEAD', $request->getMethod());
});
$this->request('HEAD', '/', array('HTTP_EXPECT' => 'something ...'));
public function testUsesCacheToRespondToHeadRequestsWhenFresh()
{
- $that = $this;
- $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) {
+ $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) {
$response->headers->set('Cache-Control', 'public, max-age=10');
$response->setContent('Hello World');
$response->setStatusCode(200);
- $that->assertNotEquals('HEAD', $request->getMethod());
+ $this->assertNotEquals('HEAD', $request->getMethod());
});
$this->request('GET', '/');
public function testSendsNoContentWhenFresh()
{
$time = \DateTime::createFromFormat('U', time());
- $that = $this;
- $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) {
+ $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) {
$response->headers->set('Cache-Control', 'public, max-age=10');
$response->headers->set('Last-Modified', $time->format(DATE_RFC2822));
});
*/
public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected)
{
- Request::setTrustedProxies($existing);
+ Request::setTrustedProxies($existing, -1);
$this->setNextResponse();
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));