Exemplo n.º 1
0
 /**
  * @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);
 }
Exemplo n.º 2
0
 /**
  * @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);
 }
Exemplo n.º 3
0
 /**
  * @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);
 }
Exemplo n.º 4
0
 /**
  * @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);
 }
Exemplo n.º 5
0
 function it_performs_action_as_given_admin_user_and_logout(SecurityServiceInterface $adminSecurityService, OrderInterface $order, AdminUserInterface $adminUser)
 {
     $adminSecurityService->getCurrentToken()->willThrow(TokenNotFoundException::class);
     $adminSecurityService->logIn($adminUser)->shouldBeCalled();
     $order->completeCheckout()->shouldBeCalled();
     $adminSecurityService->restoreToken(Argument::any())->shouldNotBeCalled();
     $adminSecurityService->logOut()->shouldBeCalled();
     $wrappedOrder = $order->getWrappedObject();
     $this->performActionAsAdminUser($adminUser, function () use($wrappedOrder) {
         $wrappedOrder->completeCheckout();
     });
 }
Exemplo n.º 6
0
 /**
  * @param SecurityServiceInterface $securityService
  * @param UserInterface $user
  * @param callable $action
  */
 private function performActionAs(SecurityServiceInterface $securityService, UserInterface $user, callable $action)
 {
     try {
         $token = $securityService->getCurrentToken();
     } catch (TokenNotFoundException $exception) {
         $token = null;
     }
     $securityService->logIn($user);
     $action();
     if (null === $token) {
         $securityService->logOut();
         return;
     }
     $securityService->restoreToken($token);
 }
Exemplo n.º 7
0
 /**
  * @Then /^(the administrator) should know about (this additional note) for (this order made by "[^"]+")$/
  */
 public function theCustomerServiceShouldKnowAboutThisAdditionalNotes(UserInterface $user, $note, OrderInterface $order)
 {
     $this->securityService->performActionAs($user, function () use($note, $order) {
         $this->showPage->open(['id' => $order->getId()]);
         Assert::true($this->showPage->hasNote($note), sprintf('I should see %s note, but I do not see', $note));
     });
 }
Exemplo n.º 8
0
 /**
  * @Given /^(this user) bought this product$/
  */
 public function thisUserBought(UserInterface $user)
 {
     $this->securityService->performActionAs($user, function () {
         $this->iProceedSelectingPaymentMethod();
         $this->iConfirmMyOrder();
     });
 }
Exemplo n.º 9
0
 /**
  * @Then /^(my) account should be verified$/
  */
 public function myAccountShouldBeVerified(ShopUserInterface $user)
 {
     $this->securityService->logIn($user);
     Assert::true($this->dashboardPage->isVerified(), 'My account should be verified.');
 }
Exemplo n.º 10
0
 /**
  * @Given /^(this user) has ("[^"]+" product) in the cart$/
  */
 public function thisUserHasProductInTheCart(UserInterface $user, ProductInterface $product)
 {
     $this->securityService->performActionAs($user, function () use($product) {
         $this->iAddProductToTheCart($product);
     });
 }