function it_logs_user_out(SessionInterface $session, CookieSetterInterface $cookieSetter) { $session->set('_security_shop', null)->shouldBeCalled(); $session->save()->shouldBeCalled(); $session->getName()->willReturn('MOCKEDSID'); $session->getId()->willReturn('xyzc123'); $cookieSetter->setCookie('MOCKEDSID', 'xyzc123')->shouldBeCalled(); $this->logOut(); }
/** * @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', ['*****@*****.**']); }
/** * @param TokenInterface $token */ private function setToken(TokenInterface $token) { $serializedToken = serialize($token); $this->session->set($this->sessionTokenVariable, $serializedToken); $this->session->save(); $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId()); }
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()); }
/** * @param string $token */ private function restorePreviousSessionToken($token) { $this->setSerializedToken($token); $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId()); }