/** * @Given I am a logged in customer */ public function iAmLoggedInCustomer() { $user = $this->userFactory->create(['email' => '*****@*****.**', 'password' => 'sylius', 'enabled' => true]); $this->userRepository->add($user); $this->securityService->logIn($user); $this->sharedStorage->set('user', $user); }
/** * @When I delete the account of :email user */ public function iDeleteAccount($email) { $user = $this->userRepository->findOneByEmail($email); $this->sharedStorage->set('deleted_user', $user); $this->customerShowPage->open(['id' => $user->getCustomer()->getId()]); $this->customerShowPage->deleteAccount(); }
/** * @Given there is an administrator with name :username */ public function thereIsAnAdministratorWithName($username) { $adminUser = $this->userFactory->create(['username' => $username]); $adminUser->setUsername($username); $this->userRepository->add($adminUser); $this->sharedStorage->set('administrator', $adminUser); }
/** * @Given I am logged in as an administrator */ public function iAmLoggedInAsAnAdministrator() { $admin = $this->testUserFactory->createDefaultAdmin(); $this->userRepository->add($admin); $this->securityService->logIn($admin->getEmail()); $this->sharedStorage->set('admin', $admin); }
/** * @Given I am a logged in customer */ public function iAmLoggedInCustomer() { $user = $this->userFactory->create(); $this->userRepository->add($user); $this->securityService->logIn($user); $this->sharedStorage->set('user', $user); }
/** * @Given /^I am logged in as "([^"]+)" administrator$/ */ public function iAmLoggedInAsAdministrator($email) { $user = $this->userRepository->findOneByEmail($email); Assert::notNull($user); $this->securityService->logIn($user); $this->sharedStorage->set('admin', $user); }
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', ['*****@*****.**']); }
/** * {@inheritdoc} */ public function logIn($email) { /** @var UserInterface $user */ $user = $this->userRepository->findOneBy(['username' => $email]); if (null === $user) { throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email)); } $this->logInUser($user); }
/** * {@inheritDoc} */ public function refreshUser(UserInterface $user) { if (!$user instanceof SyliusUserInterface) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); } if (null === ($reloadedUser = $this->userRepository->find($user->getId()))) { throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be refreshed.', $user->getId())); } return $reloadedUser; }
function it_deletes_account(UserRepositoryInterface $userRepository, ShowPageInterface $customerShowPage, SharedStorageInterface $sharedStorage, UserInterface $user, CustomerInterface $customer) { $userRepository->findOneByEmail('*****@*****.**')->willReturn($user); $sharedStorage->set('deleted_user', $user)->shouldBeCalled(); $user->getCustomer()->willReturn($customer); $customer->getId()->willReturn(1); $customerShowPage->open(['id' => 1])->shouldBeCalled(); $customerShowPage->deleteAccount()->shouldBeCalled(); $this->iDeleteAccount('*****@*****.**'); }
/** * {@inheritdoc} */ public function logIn($email, $providerKey, Session $minkSession) { $user = $this->userRepository->findOneBy(['username' => $email]); if (null === $user) { throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email)); } $token = new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles()); $this->session->set('_security_user', serialize($token)); $this->session->save(); $minkSession->setCookie($this->session->getName(), $this->session->getId()); }
/** * @Given there is an administrator identified by :email */ public function thereIsAnAdministratorIdentifiedBy($email) { $administrator = $this->userFactory->createDefaultAdmin(); $administrator->setEmail($email); $this->sharedStorage->set('administrator', $administrator); $this->userRepository->add($administrator); }
/** * @Given the account of :email was deleted */ public function accountWasDeleted($email) { $user = $this->userRepository->findOneByEmail($email); $this->sharedStorage->set('customer', $user->getCustomer()); $this->userRepository->remove($user); }
/** * @Given his account was deleted */ public function hisAccountWasDeleted() { $user = $this->sharedStorage->get('user'); $this->userRepository->remove($user); }
/** * @Given a verification email has already been sent to :email */ public function aVerificationEmailHasBeenSentTo($email) { $user = $this->userRepository->findOneByEmail($email); $this->prepareUserVerification($user); }
function it_refreshes_user(UserRepositoryInterface $userRepository, User $user, UserInterface $refreshedUser) { $userRepository->find(1)->willReturn($refreshedUser); $user->getId()->willReturn(1); $this->refreshUser($user)->shouldReturn($refreshedUser); }
/** * @Given /^(this administrator) is using ("[^"]+" locale)$/ * @Given /^(I) am using ("[^"]+" locale) for my panel$/ */ public function thisAdministratorIsUsingLocale(AdminUserInterface $adminUser, $localeCode) { $adminUser->setLocaleCode($localeCode); $this->userRepository->add($adminUser); $this->sharedStorage->set('administrator', $adminUser); }
function it_updates_user_by_user_name(UserRepositoryInterface $userRepository, User $user) { $userRepository->find(1)->willReturn($user); $user->getId()->willReturn(1); $this->refreshUser($user)->shouldReturn($user); }