Ejemplo n.º 1
0
 /**
  * @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);
 }
Ejemplo n.º 2
0
 /**
  * @Given I am logged in as an administrator
  */
 public function iAmLoggedInAsAnAdministrator()
 {
     $user = $this->userFactory->create();
     $this->userRepository->add($user);
     $this->securityService->logIn($user);
     $this->sharedStorage->set('admin', $user);
 }
Ejemplo 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);
 }
Ejemplo n.º 4
0
 /**
  * @Given the store has static content :title with name :name
  */
 public function theStoreHasStaticContentWithName($title, $name)
 {
     $staticContent = $this->staticContentExampleFactory->create(['title' => $title, 'name' => $name]);
     $this->staticContentManager->persist($staticContent);
     $this->staticContentManager->flush();
     $this->sharedStorage->set('static_content', $staticContent);
 }
Ejemplo n.º 5
0
 /**
  * @Given I am logged in as an administrator
  */
 public function iAmLoggedInAsAnAdministrator()
 {
     $user = $this->userFactory->create(['email' => '*****@*****.**', 'password' => 'sylius']);
     $this->userRepository->add($user);
     $this->securityService->logIn($user);
     $this->sharedStorage->set('administrator', $user);
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
 /**
  * @Given there is user :email identified by :password, with :country as shipping country
  */
 public function thereIsUserWithShippingCountry($email, $password, $country)
 {
     $user = $this->userFactory->create(['email' => $email, 'password' => $password, 'enabled' => true]);
     $customer = $user->getCustomer();
     $customer->setShippingAddress($this->createAddress($customer->getFirstName(), $customer->getLastName(), $country));
     $this->sharedStorage->set('user', $user);
     $this->userRepository->add($user);
 }
Ejemplo n.º 8
0
 /**
  * @Given the store has route :name with :contentTitle as its content
  */
 public function theStoreHasRouteWithAsItsContent($name, $contentTitle)
 {
     $content = $this->staticContentRepository->findOneBy(['title' => $contentTitle]);
     $route = $this->routeExampleFactory->create(['name' => $name, 'content' => $content]);
     $this->routeManager->persist($route);
     $this->routeManager->flush();
     $this->sharedStorage->set('route', $route);
 }
 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var PromotionInterface $promotion */
     $promotion = $this->promotionFactory->createNew();
     $promotion->setCode($options['code']);
     $promotion->setName($options['name']);
     $promotion->setDescription($options['description']);
     $promotion->setCouponBased($options['coupon_based']);
     $promotion->setUsageLimit($options['usage_limit']);
     $promotion->setExclusive($options['exclusive']);
     $promotion->setPriority($options['priority']);
     if (isset($options['starts_at'])) {
         $promotion->setStartsAt(new \DateTime($options['starts_at']));
     }
     if (isset($options['ends_at'])) {
         $promotion->setEndsAt(new \DateTime($options['ends_at']));
     }
     foreach ($options['channels'] as $channel) {
         $promotion->addChannel($channel);
     }
     foreach ($options['rules'] as $rule) {
         /** @var PromotionRuleInterface $promotionRule */
         $promotionRule = $this->promotionRuleExampleFactory->create($rule);
         $promotion->addRule($promotionRule);
     }
     foreach ($options['actions'] as $action) {
         /** @var PromotionActionInterface $promotionAction */
         $promotionAction = $this->promotionActionExampleFactory->create($action);
         $promotion->addAction($promotionAction);
     }
     return $promotion;
 }
 /**
  * @param array $options
  */
 public final function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $i = 0;
     foreach ($options['custom'] as $resourceOptions) {
         $resource = $this->exampleFactory->create($resourceOptions);
         $this->objectManager->persist($resource);
         ++$i;
         if (0 === $i % 10) {
             $this->objectManager->flush();
             $this->objectManager->clear();
         }
     }
     $this->objectManager->flush();
     $this->objectManager->clear();
 }