示例#1
0
 /**
  * @Then /^an email with shipment's details of (this order) should be sent to "([^"]+)"$/
  */
 public function anEmailWithShipmentDetailsOfOrderShouldBeSentTo(OrderInterface $order, $recipient)
 {
     $this->assertEmailContainsMessageTo($order->getNumber(), $recipient);
     $this->assertEmailContainsMessageTo($order->getLastShipment()->getMethod()->getName(), $recipient);
     $tracking = $this->sharedStorage->get('tracking_code');
     $this->assertEmailContainsMessageTo($tracking, $recipient);
 }
示例#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);
 }
示例#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);
 }
示例#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);
 }
示例#5
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);
 }
 /**
  * @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);
 }
示例#7
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);
 }
示例#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);
 }
示例#9
0
 /**
  * @When I set :channel channel theme to :theme
  */
 public function iSetChannelThemeTo(ChannelInterface $channel, ThemeInterface $theme)
 {
     $this->channelUpdatePage->open(['id' => $channel->getId()]);
     $this->channelUpdatePage->setTheme($theme);
     $this->channelUpdatePage->saveChanges();
     $this->sharedStorage->set('channel', $channel);
     $this->sharedStorage->set('theme', $theme);
 }
 /**
  * @Given the store has a product option :productOptionName with a code :productOptionCode
  */
 public function theStoreHasAProductOptionWithACode($productOptionName, $productOptionCode)
 {
     $productOption = $this->productOptionFactory->createNew();
     $productOption->setCode($productOptionCode);
     $productOption->setName($productOptionName);
     $this->sharedStorage->set('product_option', $productOption);
     $this->productOptionRepository->add($productOption);
 }
 /**
  * @param string $name
  */
 private function createCustomerGroup($name)
 {
     /** @var CustomerGroupInterface $customerGroup */
     $customerGroup = $this->customerGroupFactory->createNew();
     $customerGroup->setName(ucfirst($name));
     $this->sharedStorage->set('customer_group', $customerGroup);
     $this->customerGroupRepository->add($customerGroup);
 }
示例#12
0
 /**
  * @When I create a new channel :channelName
  */
 public function iCreateNewChannel($channelName)
 {
     $this->channelCreatePage->open();
     $this->channelCreatePage->nameIt($channelName);
     $this->channelCreatePage->specifyCode($channelName);
     $this->channelCreatePage->create();
     $channel = $this->channelRepository->findOneBy(['name' => $channelName]);
     $this->sharedStorage->set('channel', $channel);
 }
 /**
  * @param string $type
  * @param string $name
  * @param string|null $code
  */
 private function createProductAttribute($type, $name, $code = null)
 {
     $productAttribute = $this->productAttributeFactory->createTyped($type);
     if (null === $code) {
         $code = str_replace(' ', '_', strtoupper($name));
     }
     $productAttribute->setCode($code);
     $productAttribute->setName($name);
     $this->productAttributeRepository->add($productAttribute);
     $this->sharedStorage->set('product_attribute', $productAttribute);
 }
示例#14
0
 /**
  * @param string $type
  * @param string $name
  * @param string|null $code
  */
 private function createProductAttribute($type, $name, $code = null)
 {
     $productAttribute = $this->productAttributeFactory->createTyped($type);
     if (null === $code) {
         $code = StringInflector::nameToUppercaseCode($name);
     }
     $productAttribute->setCode($code);
     $productAttribute->setName($name);
     $this->productAttributeRepository->add($productAttribute);
     $this->sharedStorage->set('product_attribute', $productAttribute);
 }
示例#15
0
 /**
  * @param string $shippingCategoryName
  * @param string $shippingCategoryCode
  */
 private function createShippingCategory($shippingCategoryName, $shippingCategoryCode = null)
 {
     /** @var ShippingCategoryInterface $shippingCategory */
     $shippingCategory = $this->shippingCategoryFactory->createNew();
     $shippingCategory->setName($shippingCategoryName);
     $shippingCategory->setCode($shippingCategoryCode);
     if (null === $shippingCategoryCode) {
         $shippingCategory->setCode(StringInflector::nameToCode($shippingCategoryName));
     }
     $this->shippingCategoryRepository->add($shippingCategory);
     $this->sharedStorage->set('shipping_category', $shippingCategory);
 }
示例#16
0
 /**
  * @param string $name
  * @param string|null $code
  * @param int|null $position
  * @param ZoneInterface|null $zone
  * @param string $locale
  * @param array $configuration
  * @param string $calculator
  * @param bool $enabled
  * @param bool $addForCurrentChannel
  */
 private function createShippingMethod($name, $code = null, $position = null, ZoneInterface $zone = null, $locale = 'en', $configuration = ['amount' => 0], $calculator = DefaultCalculators::FLAT_RATE, $enabled = true, $addForCurrentChannel = true)
 {
     if (null === $zone) {
         $zone = $this->sharedStorage->get('zone');
     }
     if (null === $code) {
         $code = $this->generateCodeFromNameAndZone($name, $zone->getCode());
     }
     /** @var ShippingMethodInterface $shippingMethod */
     $shippingMethod = $this->shippingMethodFactory->createNew();
     $shippingMethod->setCode($code);
     $shippingMethod->setName($name);
     $shippingMethod->setPosition($position);
     $shippingMethod->setCurrentLocale($locale);
     $shippingMethod->setConfiguration($configuration);
     $shippingMethod->setCalculator($calculator);
     $shippingMethod->setZone($zone);
     $shippingMethod->setEnabled($enabled);
     if ($addForCurrentChannel && $this->sharedStorage->has('channel')) {
         $channel = $this->sharedStorage->get('channel');
         $channel->addShippingMethod($shippingMethod);
     }
     $this->shippingMethodRepository->add($shippingMethod);
     $this->sharedStorage->set('shipping_method', $shippingMethod);
 }
示例#17
0
 /**
  * @param string $name
  * @param string|null $code
  * @param int|null $position
  * @param ZoneInterface|null $zone
  * @param string $locale
  * @param array $configuration
  * @param string $calculator
  * @param bool $enabled
  * @param bool $addForCurrentChannel
  * @param array $channels
  *
  * @return ShippingMethodInterface
  */
 private function createShippingMethod($name, $code = null, $position = null, ZoneInterface $zone = null, $locale = 'en', array $configuration = [], $calculator = DefaultCalculators::FLAT_RATE, $enabled = true, $addForCurrentChannel = true, array $channels = [])
 {
     $channel = $this->sharedStorage->get('channel');
     if (null === $zone) {
         $zone = $this->sharedStorage->get('zone');
     }
     if (null === $code) {
         $code = $this->generateCodeFromNameAndZone($name, $zone->getCode());
     }
     if (empty($configuration)) {
         $configuration = $this->getConfigurationByChannels([$channel]);
     }
     /** @var ShippingMethodInterface $shippingMethod */
     $shippingMethod = $this->shippingMethodFactory->createNew();
     $shippingMethod->setCode($code);
     $shippingMethod->setName($name);
     $shippingMethod->setPosition($position);
     $shippingMethod->setCurrentLocale($locale);
     $shippingMethod->setConfiguration($configuration);
     $shippingMethod->setCalculator($calculator);
     $shippingMethod->setZone($zone);
     $shippingMethod->setEnabled($enabled);
     if ($addForCurrentChannel && $channel) {
         $shippingMethod->addChannel($channel);
     }
     if (!$addForCurrentChannel) {
         foreach ($channels as $channel) {
             $shippingMethod->addChannel($channel);
         }
     }
     $this->shippingMethodRepository->add($shippingMethod);
     $this->sharedStorage->set('shipping_method', $shippingMethod);
     return $shippingMethod;
 }
示例#18
0
 /**
  * @param UserInterface $user
  */
 private function prepareUserVerification(UserInterface $user)
 {
     $token = 'marryhadalittlelamb';
     $this->sharedStorage->set('verification_token', $token);
     $user->setEmailVerificationToken($token);
     $this->userManager->flush();
 }
 /**
  * @param string $element
  * @param string $message
  */
 private function assertValidationMessage($element, $message)
 {
     $product = $this->sharedStorage->has('product') ? $this->sharedStorage->get('product') : null;
     /** @var CreatePageInterface|UpdatePageInterface $currentPage */
     $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createSimpleProductPage, $this->createConfigurableProductPage, $this->updateSimpleProductPage, $this->updateConfigurableProductPage], $product);
     Assert::same($currentPage->getValidationMessage($element), $message);
 }
示例#20
0
 /**
  * @Then /^(this product) should have(?:| also) an image with a code "([^"]*)"$/
  * @Then /^the (product "[^"]+") should have(?:| also) an image with a code "([^"]*)"$/
  */
 public function thisProductShouldHaveAnImageWithCode(ProductInterface $product, $code)
 {
     $this->sharedStorage->set('product', $product);
     /** @var UpdateSimpleProductPageInterface|UpdateConfigurableProductPageInterface $currentPage */
     $currentPage = $this->resolveCurrentPage();
     Assert::true($currentPage->isImageWithCodeDisplayed($code), sprintf('Image with a code %s should have been displayed.', $code));
 }
示例#21
0
 /**
  * @Given the store has a zone :zoneName with code :code
  * @Given the store also has a zone :zoneName with code :code
  */
 public function theStoreHasAZoneWithCode($zoneName, $code)
 {
     $zone = $this->zoneFactory->createTyped(ZoneInterface::TYPE_ZONE);
     $zone->setCode($code);
     $zone->setName($zoneName);
     $this->sharedStorage->set('zone', $zone);
     $this->zoneRepository->add($zone);
 }
示例#22
0
 /**
  * @When /^I delete the ("[^"]+" product)$/
  */
 public function iDeleteTheProduct(ProductInterface $product)
 {
     try {
         $this->sharedStorage->set('deleted_product', $product);
         $this->productRepository->remove($product);
     } catch (DBALException $exception) {
         $this->sharedStorage->set('last_exception', $exception);
     }
 }
 /**
  * @Given /^(this country)(?:| also) has the "([^"]+)" province with "([^"]+)" code$/
  * @Given /^(?:|the )(country "[^"]+") has the "([^"]+)" province with "([^"]+)" code$/
  */
 public function theCountryHasProvinceWithCode(CountryInterface $country, $name, $code)
 {
     /** @var ProvinceInterface $province */
     $province = $this->provinceFactory->createNew();
     $province->setName($name);
     $province->setCode($code);
     $country->addProvince($province);
     $this->sharedStorage->set('province', $province);
     $this->countryManager->flush();
 }
示例#24
0
 /**
  * @param string $name
  * @param string|null $code
  */
 private function createProductAssociationType($name, $code = null)
 {
     if (null === $code) {
         $code = $this->generateCodeFromName($name);
     }
     /** @var ProductAssociationTypeInterface $productAssociationType */
     $productAssociationType = $this->productAssociationTypeFactory->createNew();
     $productAssociationType->setCode($code);
     $productAssociationType->setName($name);
     $this->productAssociationTypeRepository->add($productAssociationType);
     $this->sharedStorage->set('product_association_type', $productAssociationType);
 }
示例#25
0
 /**
  * @Given the store has promotion :promotionName with coupon :couponCode
  * @Given the store has also promotion :promotionName with coupon :couponCode
  */
 public function thereIsPromotionWithCoupon($promotionName, $couponCode)
 {
     /** @var CouponInterface $coupon */
     $coupon = $this->couponFactory->createNew();
     $coupon->setCode($couponCode);
     $promotion = $this->testPromotionFactory->createForChannel($promotionName, $this->sharedStorage->get('channel'));
     $promotion->addCoupon($coupon);
     $promotion->setCouponBased(true);
     $this->promotionRepository->add($promotion);
     $this->sharedStorage->set('promotion', $promotion);
     $this->sharedStorage->set('coupon', $coupon);
 }
示例#26
0
 /**
  * @param CustomerInterface $customer
  * @param ChannelInterface|null $channel
  * @param string|null $currencyCode
  * @param string|null $localeCode
  *
  * @return OrderInterface
  */
 private function createCart(CustomerInterface $customer, ChannelInterface $channel = null, $currencyCode = null, $localeCode = null)
 {
     /** @var OrderInterface $order */
     $order = $this->orderFactory->createNew();
     $order->setCustomer($customer);
     $order->setChannel(null !== $channel ? $channel : $this->sharedStorage->get('channel'));
     $order->setLocaleCode(null !== $localeCode ? $localeCode : $this->sharedStorage->get('locale')->getCode());
     $currencyCode = $currencyCode ? $currencyCode : $order->getChannel()->getBaseCurrency()->getCode();
     $currency = $this->currencyRepository->findOneBy(['code' => $currencyCode]);
     $order->setCurrencyCode($currency->getCode());
     return $order;
 }
示例#27
0
 /**
  * @param CustomerInterface $customer
  * @param string $number
  * @param ChannelInterface|null $channel
  * @param string|null $currencyCode
  *
  * @return OrderInterface
  */
 private function createOrder(CustomerInterface $customer, $number = null, ChannelInterface $channel = null, $currencyCode = null)
 {
     $order = $this->orderFactory->createNew();
     $order->setCustomer($customer);
     if (null !== $number) {
         $order->setNumber($number);
     }
     $order->setChannel(null !== $channel ? $channel : $this->sharedStorage->get('channel'));
     $order->setCurrencyCode(null !== $currencyCode ? $currencyCode : $this->sharedStorage->get('currency')->getCode());
     $order->complete();
     return $order;
 }
示例#28
0
 /**
  * @param ProductInterface $product
  * @param $productVariantName
  * @param int $price
  * @param string $code
  * @param ChannelInterface $channel
  */
 private function createProductVariant(ProductInterface $product, $productVariantName, $price, $code, ChannelInterface $channel = null)
 {
     $product->setVariantSelectionMethod(ProductInterface::VARIANT_SELECTION_CHOICE);
     /** @var ProductVariantInterface $variant */
     $variant = $this->productVariantFactory->createNew();
     $variant->setName($productVariantName);
     $variant->setCode($code);
     $variant->setProduct($product);
     $variant->addChannelPricing($this->createChannelPricingForChannel($price, $channel));
     $product->addVariant($variant);
     $this->objectManager->flush();
     $this->sharedStorage->set('variant', $variant);
 }
示例#29
0
 /**
  * @param string $name
  * @param string $code
  * @param bool $addForCurrentChannel
  * @param string $description
  */
 private function createPaymentMethodFromNameAndCode($name, $code, $description = '', $addForCurrentChannel = true)
 {
     /** @var PaymentMethodInterface $paymentMethod */
     $paymentMethod = $this->paymentMethodFactory->createNew();
     $paymentMethod->setName(ucfirst($name));
     $paymentMethod->setCode($code);
     $paymentMethod->setGateway($this->paymentMethodNameToGatewayConverter->convert($name));
     $paymentMethod->setDescription($description);
     if ($addForCurrentChannel && $this->sharedStorage->has('channel')) {
         $channel = $this->sharedStorage->get('channel');
         $channel->addPaymentMethod($paymentMethod);
     }
     $this->sharedStorage->set('payment_method', $paymentMethod);
     $this->paymentMethodRepository->add($paymentMethod);
 }
示例#30
0
 /**
  * @param string $email
  * @param string $password
  * @param bool $enabled
  * @param string|null $firstName
  * @param string|null $lastName
  * @param string|null $role
  */
 private function createCustomerWithUserAccount($email, $password, $enabled = true, $firstName = null, $lastName = null, $role = null)
 {
     $user = $this->userFactory->createNew();
     /** @var CustomerInterface $customer */
     $customer = $this->customerFactory->createNew();
     $customer->setFirstName($firstName);
     $customer->setLastName($lastName);
     $customer->setEmail($email);
     $user->setUsername($email);
     $user->setPlainPassword($password);
     $user->setEnabled($enabled);
     $user->addRole($role);
     $customer->setUser($user);
     $this->sharedStorage->set('customer', $customer);
     $this->customerRepository->add($customer);
 }