コード例 #1
0
 function it_throws_a_channel_not_found_exception_if_channel_with_given_code_was_not_found(FakeChannelCodeProviderInterface $fakeChannelCodeProvider, ChannelRepositoryInterface $channelRepository, RequestStack $requestStack, Request $request)
 {
     $requestStack->getMasterRequest()->willReturn($request);
     $fakeChannelCodeProvider->getCode($request)->willReturn('CHANNEL_CODE');
     $channelRepository->findOneByCode('CHANNEL_CODE')->willReturn(null);
     $this->shouldThrow(ChannelNotFoundException::class)->during('getChannel');
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getChannel()
 {
     $fakeChannelCode = $this->fakeChannelCodeProvider->getCode($this->getMasterRequest());
     $channel = $this->channelRepository->findOneByCode($fakeChannelCode);
     $this->assertChannelWasFound($channel);
     return $channel;
 }
コード例 #3
0
 /**
  * @param FilterResponseEvent $filterResponseEvent
  */
 public function onKernelResponse(FilterResponseEvent $filterResponseEvent)
 {
     if (HttpKernelInterface::SUB_REQUEST === $filterResponseEvent->getRequestType()) {
         return;
     }
     $fakeChannelCode = $this->fakeChannelCodeProvider->getCode($filterResponseEvent->getRequest());
     if (null === $fakeChannelCode) {
         return;
     }
     $response = $filterResponseEvent->getResponse();
     $response->headers->setCookie(new Cookie('_channel_code', $fakeChannelCode));
 }
コード例 #4
0
 function it_persists_fake_channel_codes_in_a_cookie(FakeChannelCodeProviderInterface $fakeHostnameProvider, FilterResponseEvent $filterResponseEvent, Request $request, Response $response, ResponseHeaderBag $responseHeaderBag)
 {
     $filterResponseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
     $filterResponseEvent->getRequest()->willReturn($request);
     $fakeHostnameProvider->getCode($request)->willReturn('fake_channel_code');
     $filterResponseEvent->getResponse()->willReturn($response);
     $response->headers = $responseHeaderBag;
     $responseHeaderBag->setCookie(Argument::that(function (Cookie $cookie) {
         if ($cookie->getName() !== '_channel_code') {
             return false;
         }
         if ($cookie->getValue() !== 'fake_channel_code') {
             return false;
         }
         return true;
     }))->shouldBeCalled();
     $this->onKernelResponse($filterResponseEvent);
 }