| @@ 341-353 (lines=13) @@ | ||
| 338 | /** |
|
| 339 | * Unsafe methods should abort before even attempting to match rules. |
|
| 340 | */ |
|
| 341 | public function testUnsafeMethod() |
|
| 342 | { |
|
| 343 | $subscriber = $this->getMockBuilder('FOS\HttpCacheBundle\EventListener\CacheControlSubscriber') |
|
| 344 | ->setMethods(array('matchRule')) |
|
| 345 | ->getMock() |
|
| 346 | ; |
|
| 347 | $subscriber->expects($this->never()) |
|
| 348 | ->method('matchRule') |
|
| 349 | ; |
|
| 350 | $event = $this->buildEvent('POST'); |
|
| 351 | ||
| 352 | $subscriber->onKernelResponse($event); |
|
| 353 | } |
|
| 354 | ||
| 355 | /** |
|
| 356 | * Safe methods should get into the matchRule |
|
| @@ 360-372 (lines=13) @@ | ||
| 357 | * @dataProvider getSafeMethods |
|
| 358 | * @param $method |
|
| 359 | */ |
|
| 360 | public function testSafeMethodsTriggersMatchRule($method) |
|
| 361 | { |
|
| 362 | $subscriber = $this->getMockBuilder('FOS\HttpCacheBundle\EventListener\CacheControlSubscriber') |
|
| 363 | ->setMethods(array('matchRule')) |
|
| 364 | ->getMock() |
|
| 365 | ; |
|
| 366 | $subscriber->expects($this->once()) |
|
| 367 | ->method('matchRule') |
|
| 368 | ; |
|
| 369 | $event = $this->buildEvent($method); |
|
| 370 | ||
| 371 | $subscriber->onKernelResponse($event); |
|
| 372 | } |
|
| 373 | ||
| 374 | /** |
|
| 375 | * Safe Methods data |
|
| @@ 412-422 (lines=11) @@ | ||
| 409 | * |
|
| 410 | * @return \PHPUnit_Framework_MockObject_MockObject|CacheControlSubscriber |
|
| 411 | */ |
|
| 412 | protected function getCacheControl(array $headers) |
|
| 413 | { |
|
| 414 | $subscriber = $this->getMockBuilder('FOS\HttpCacheBundle\EventListener\CacheControlSubscriber') |
|
| 415 | ->setMethods(array('matchRule')) |
|
| 416 | ->getMock() |
|
| 417 | ; |
|
| 418 | ||
| 419 | $subscriber->expects($this->once())->method('matchRule')->will($this->returnValue($headers)); |
|
| 420 | ||
| 421 | return $subscriber; |
|
| 422 | } |
|
| 423 | } |
|
| 424 | ||