/** * @param UserInterface $user */ private function logInUser(UserInterface $user) { $token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles()); $this->session->set($this->sessionTokenVariable, serialize($token)); $this->session->save(); $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId()); }
function it_does_not_log_user_in_if_user_was_not_found(UserRepositoryInterface $userRepository, SessionInterface $session, CookieSetterInterface $cookieSetter) { $userRepository->findOneBy(['username' => '*****@*****.**'])->willReturn(null); $session->set(Argument::cetera())->shouldNotBeCalled(); $session->save()->shouldNotBeCalled(); $cookieSetter->setCookie(Argument::cetera())->shouldNotBeCalled(); $this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', ['*****@*****.**']); }
function it_sets_channel_as_current(CookieSetterInterface $cookieSetter, ChannelInterface $channel) { $channel->getCode()->willReturn('CHANNEL_CODE'); $cookieSetter->setCookie('_channel_code', 'CHANNEL_CODE')->shouldBeCalled(); $this->setChannel($channel); }
/** * {@inheritdoc} */ public function setChannel(ChannelInterface $channel) { $this->cookieSetter->setCookie('_channel_code', $channel->getCode()); }