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