|
@@ 60-75 (lines=16) @@
|
| 57 |
|
$this->assertEquals('max-age=0, no-cache, private', $response->headers->get('Cache-Control')); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
public function testOnKernelRequestNonMaster() |
| 61 |
|
{ |
| 62 |
|
$request = new Request(); |
| 63 |
|
$request->setMethod('HEAD'); |
| 64 |
|
|
| 65 |
|
$requestMatcher = $this->getRequestMatcher($request, true); |
| 66 |
|
$hashGenerator = \Mockery::mock('\FOS\HttpCache\UserContext\HashGenerator'); |
| 67 |
|
$hashGenerator->shouldReceive('generateHash')->never(); |
| 68 |
|
|
| 69 |
|
$userContextSubscriber = new UserContextSubscriber($requestMatcher, $hashGenerator, array('X-SessionId'), 'X-Hash'); |
| 70 |
|
$event = $this->getKernelRequestEvent($request, HttpKernelInterface::SUB_REQUEST); |
| 71 |
|
|
| 72 |
|
$userContextSubscriber->onKernelRequest($event); |
| 73 |
|
|
| 74 |
|
$this->assertNull($event->getResponse()); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
public function testOnKernelRequestCached() |
| 78 |
|
{ |
|
@@ 100-117 (lines=18) @@
|
| 97 |
|
$this->assertEquals('max-age=30, public', $response->headers->get('Cache-Control')); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
public function testOnKernelRequestNotMatched() |
| 101 |
|
{ |
| 102 |
|
$request = new Request(); |
| 103 |
|
$request->setMethod('HEAD'); |
| 104 |
|
|
| 105 |
|
$requestMatcher = $this->getRequestMatcher($request, false); |
| 106 |
|
$hashGenerator = \Mockery::mock('\FOS\HttpCache\UserContext\HashGenerator'); |
| 107 |
|
$hashGenerator->shouldReceive('generateHash')->andReturn('hash'); |
| 108 |
|
|
| 109 |
|
$userContextSubscriber = new UserContextSubscriber($requestMatcher, $hashGenerator, array('X-SessionId'), 'X-Hash'); |
| 110 |
|
$event = $this->getKernelRequestEvent($request); |
| 111 |
|
|
| 112 |
|
$userContextSubscriber->onKernelRequest($event); |
| 113 |
|
|
| 114 |
|
$response = $event->getResponse(); |
| 115 |
|
|
| 116 |
|
$this->assertNull($response); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
public function testOnKernelResponse() |
| 120 |
|
{ |