/**
  * {@inheritdoc}
  */
 public function getChannel()
 {
     $fakeChannelCode = $this->fakeChannelCodeProvider->getCode($this->getMasterRequest());
     $channel = $this->channelRepository->findOneByCode($fakeChannelCode);
     $this->assertChannelWasFound($channel);
     return $channel;
 }
Beispiel #2
0
 /**
  * @param string $channelCode
  *
  * @return ChannelInterface|null
  */
 private function findChannelByCodeOrFindFirst($channelCode)
 {
     $channel = null;
     if (null !== $channelCode) {
         $channel = $this->channelRepository->findOneByCode($channelCode);
     }
     if (null === $channel) {
         $channels = $this->channelRepository->findAll();
         $channel = current($channels) === false ? null : current($channels);
     }
     return $channel;
 }
 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');
 }