|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Security\Tests\Http\RememberMe;
|
13 | 13 |
|
| 14 | +use Symfony\Component\HttpKernel\HttpKernelInterface; |
14 | 15 | use Symfony\Component\Security\Http\RememberMe\ResponseListener;
|
15 | 16 | use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
16 | 17 | use Symfony\Component\HttpFoundation\Request;
|
@@ -41,7 +42,22 @@ public function testRememberMeCookieIsSentWithResponse()
|
41 | 42 | $listener->onKernelResponse($this->getEvent($request, $response));
|
42 | 43 | }
|
43 | 44 |
|
44 |
| - public function testRemmeberMeCookieIsNotSendWithResponse() |
| 45 | + public function testRememberMeCookieIsNotSendWithResponseForSubRequests() |
| 46 | + { |
| 47 | + $cookie = new Cookie('rememberme'); |
| 48 | + |
| 49 | + $request = $this->getRequest(array( |
| 50 | + RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie, |
| 51 | + )); |
| 52 | + |
| 53 | + $response = $this->getResponse(); |
| 54 | + $response->headers->expects($this->never())->method('setCookie'); |
| 55 | + |
| 56 | + $listener = new ResponseListener(); |
| 57 | + $listener->onKernelResponse($this->getEvent($request, $response, HttpKernelInterface::SUB_REQUEST)); |
| 58 | + } |
| 59 | + |
| 60 | + public function testRememberMeCookieIsNotSendWithResponse() |
45 | 61 | {
|
46 | 62 | $request = $this->getRequest();
|
47 | 63 |
|
@@ -78,13 +94,14 @@ private function getResponse()
|
78 | 94 | return $response;
|
79 | 95 | }
|
80 | 96 |
|
81 |
| - private function getEvent($request, $response) |
| 97 | + private function getEvent($request, $response, $type = HttpKernelInterface::MASTER_REQUEST) |
82 | 98 | {
|
83 | 99 | $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')
|
84 | 100 | ->disableOriginalConstructor()
|
85 | 101 | ->getMock();
|
86 | 102 |
|
87 | 103 | $event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
|
| 104 | + $event->expects($this->any())->method('getRequestType')->will($this->returnValue($type)); |
88 | 105 | $event->expects($this->any())->method('getResponse')->will($this->returnValue($response));
|
89 | 106 |
|
90 | 107 | return $event;
|
|
0 commit comments