示例#1
0
 /**
  * @Given /^the store has disabled country "([^"]*)"$/
  */
 public function theStoreHasDisabledCountry($countryName)
 {
     $country = $this->createCountryNamed(trim($countryName));
     $country->disable();
     $this->sharedStorage->set('country', $country);
     $this->countryRepository->add($country);
 }
示例#2
0
 /**
  * @Given /^the store operates on (?:a|another) channel named "([^"]+)"$/
  */
 public function theStoreOperatesOnAChannelNamed($channelName)
 {
     $channel = $this->channelFactory->createNamed($channelName);
     $channel->setCode($channelName);
     $this->channelRepository->add($channel);
     $this->sharedStorage->set('channel', $channel);
 }
示例#3
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);
 }
示例#4
0
 /**
  * @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();
 }
示例#5
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);
 }
示例#6
0
 /**
  * @Given the store has disabled locale :localeName
  */
 public function theStoreHasDisabledLocale($localeName)
 {
     $locale = $this->localeFactory->createNew();
     $locale->setCode($this->localeNameConverter->convertToCode($localeName));
     $locale->disable();
     $this->sharedStorage->set('locale', $locale);
     $this->localeRepository->add($locale);
 }
示例#7
0
 /**
  * @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);
 }
示例#8
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);
 }
示例#9
0
 /**
  * @Given /^the store has a product "([^"]+)"$/
  * @Given /^the store has a product "([^"]+)" priced at ("[^"]+")$/
  */
 public function storeHasAProductPricedAt($productName, $price = 0)
 {
     $product = $this->productFactory->createNew();
     $product->setName($productName);
     $product->setPrice($price);
     $product->setDescription('Awesome ' . $productName);
     $channel = $this->sharedStorage->get('channel');
     $product->addChannel($channel);
     $this->productRepository->add($product);
     $this->sharedStorage->set('product', $product);
 }
示例#10
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 = str_replace(' ', '_', strtoupper($name));
     }
     $productAttribute->setCode($code);
     $productAttribute->setName($name);
     $this->productAttributeRepository->add($productAttribute);
     $this->sharedStorage->set('product_attribute', $productAttribute);
 }
示例#11
0
 function it_creates_promotion_with_coupon(SharedStorageInterface $sharedStorage, CouponFactoryInterface $couponFactory, TestPromotionFactoryInterface $testPromotionFactory, PromotionRepositoryInterface $promotionRepository, ChannelInterface $channel, CouponInterface $coupon, PromotionInterface $promotion)
 {
     $couponFactory->createNew()->willReturn($coupon);
     $coupon->setCode('Coupon galore')->shouldBeCalled();
     $sharedStorage->get('channel')->willReturn($channel);
     $testPromotionFactory->createForChannel('Promotion galore', $channel)->willReturn($promotion);
     $promotion->addCoupon($coupon)->shouldBeCalled();
     $promotion->setCouponBased(true)->shouldBeCalled();
     $promotionRepository->add($promotion)->shouldBeCalled();
     $sharedStorage->set('promotion', $promotion)->shouldBeCalled();
     $sharedStorage->set('coupon', $coupon)->shouldBeCalled();
     $this->thereIsPromotionWithCoupon('Promotion galore', 'Coupon galore');
 }
示例#12
0
 function it_deletes_an_order(SharedStorageInterface $sharedStorage, AddressInterface $shippingAddress, AddressInterface $billingAddress, AdjustmentInterface $adjustment, OrderRepositoryInterface $orderRepository, OrderInterface $order)
 {
     $orderRepository->findOneBy(['number' => '#00000000'])->willReturn($order);
     $order->getBillingAddress()->willReturn($billingAddress);
     $order->getShippingAddress()->willReturn($shippingAddress);
     $order->getAdjustments()->willReturn([$adjustment]);
     $billingAddress->getId()->willReturn(3);
     $shippingAddress->getId()->willReturn(2);
     $adjustment->getId()->willReturn(1);
     $orderRepository->remove($order)->shouldBeCalled();
     $sharedStorage->set('deleted_adjustments', [1])->shouldBeCalled();
     $sharedStorage->set('deleted_addresses', [2, 3])->shouldBeCalled();
     $this->iDeleteTheOrder('#00000000');
 }
示例#13
0
 /**
  * @When I delete the order :orderNumber
  */
 public function iDeleteTheOrder($orderNumber)
 {
     /** @var OrderInterface $order */
     $order = $this->orderRepository->findOneBy(['number' => $orderNumber]);
     if (null === $order) {
         throw new \InvalidArgumentException(sprintf('Order with %s number was not found in an order repository', $orderNumber));
     }
     $adjustmentsId = [];
     foreach ($order->getAdjustments() as $adjustment) {
         $adjustmentsId[] = $adjustment->getId();
     }
     $this->sharedStorage->set('deleted_adjustments', $adjustmentsId);
     $this->sharedStorage->set('deleted_addresses', [$order->getShippingAddress()->getId(), $order->getBillingAddress()->getId()]);
     $this->orderRepository->remove($order);
 }
示例#14
0
 /**
  * @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);
 }
示例#15
0
 /**
  * @Given /^(I) placed (an order "[^"]+")$/
  */
 public function iPlacedAnOrder(UserInterface $user, $orderNumber)
 {
     $customer = $user->getCustomer();
     $order = $this->createOrder($customer, $orderNumber);
     $this->sharedStorage->set('order', $order);
     $this->orderRepository->add($order);
 }
示例#16
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);
 }
示例#17
0
 function it_creates_a_tax_category_with_name_and_code(SharedStorageInterface $sharedStorage, TaxCategoryInterface $taxCategory, TaxCategoryRepositoryInterface $taxCategoryRepository, FactoryInterface $taxCategoryFactory)
 {
     $taxCategoryFactory->createNew()->willReturn($taxCategory);
     $taxCategory->setName('Alcohol')->shouldBeCalled();
     $taxCategory->setCode('alcohol')->shouldBeCalled();
     $taxCategoryRepository->add($taxCategory)->shouldBeCalled();
     $sharedStorage->set('tax_category', $taxCategory)->shouldBeCalled();
     $this->theStoreHasTaxCategoryWithCode('Alcohol', 'alcohol');
 }
示例#18
0
 function it_deletes_a_product(AdminProductShowPageInterface $adminProductShowPage, SharedStorageInterface $sharedStorage, ProductInterface $product)
 {
     $sharedStorage->set('product', $product)->shouldBeCalled();
     $product->getName()->willReturn('Model');
     $product->getId()->willReturn(1);
     $adminProductShowPage->open(['id' => 1])->shouldBeCalled();
     $adminProductShowPage->deleteProduct()->shouldBeCalled();
     $this->iDeleteProduct($product);
 }
示例#19
0
 /**
  * @When I want to modify the :product product
  * @When /^I want to modify (this product)$/
  */
 public function iWantToModifyAProduct(ProductInterface $product)
 {
     $this->sharedStorage->set('product', $product);
     if ($product->isSimple()) {
         $this->updateSimpleProductPage->open(['id' => $product->getId()]);
         return;
     }
     $this->updateConfigurableProductPage->open(['id' => $product->getId()]);
 }
示例#20
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);
     }
 }
示例#21
0
 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('*****@*****.**');
 }
示例#22
0
 function it_throws_invalid_argument_exception_if_cannot_convert_locale_name_to_code(FactoryInterface $localeFactory, LocaleInterface $locale, LocaleNameConverterInterface $localeNameConverter, RepositoryInterface $localeRepository, SharedStorageInterface $sharedStorage)
 {
     $localeFactory->createNew()->willReturn($locale);
     $localeNameConverter->convertToCode('xyz')->willThrow(\InvalidArgumentException::class);
     $locale->setCode('no')->shouldNotBeCalled();
     $sharedStorage->set('locale', $locale)->shouldNotBeCalled();
     $localeRepository->add($locale)->shouldNotBeCalled();
     $this->shouldThrow(\InvalidArgumentException::class)->during('theStoreHasLocale', ['xyz']);
     $this->shouldThrow(\InvalidArgumentException::class)->during('theStoreHasDisabledLocale', ['xyz']);
 }
示例#23
0
 /**
  * @Given /^(this country) has the "([^"]+)" province with "([^"]+)" code$/
  * @Given /^(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();
 }
 function it_configures_that_store_operates_in_given_country_disabled_by_default(CountryInterface $country, CountryNameConverterInterface $nameToCodeConverter, FactoryInterface $countryFactory, RepositoryInterface $countryRepository, SharedStorageInterface $sharedStorage)
 {
     $countryFactory->createNew()->willReturn($country);
     $nameToCodeConverter->convertToCode('France')->willReturn('FR');
     $country->setCode('FR')->shouldBeCalled();
     $country->disable()->shouldBeCalled();
     $sharedStorage->set('country', $country)->shouldBeCalled();
     $countryRepository->add($country)->shouldBeCalled();
     $this->theStoreHasDisabledCountry('France');
 }
示例#25
0
 /**
  * @Given /^the (product "[^"]+") has "([^"]+)" variant priced at ("[^"]+")$/
  * @Given /^(this product) has "([^"]+)" variant priced at ("[^"]+")$/
  */
 public function theProductHasVariantPricedAt(ProductInterface $product, $productVariantName, $price)
 {
     /** @var ProductVariantInterface $variant */
     $variant = $this->productVariantFactory->createNew();
     $variant->setPresentation($productVariantName);
     $variant->setPrice($price);
     $variant->setProduct($product);
     $product->addVariant($variant);
     $this->objectManager->flush();
     $this->sharedStorage->set('variant', $variant);
 }
示例#26
0
 function it_creates_new_product_variant(SharedStorageInterface $sharedStorage, FactoryInterface $productVariantFactory, ObjectManager $objectManager, ProductInterface $product, ProductVariantInterface $productVariant)
 {
     $productVariantFactory->createNew()->willReturn($productVariant);
     $productVariant->setPresentation('Han Solo Mug')->shouldBeCalled();
     $productVariant->setPrice(2500)->shouldBeCalled();
     $productVariant->setProduct($product)->shouldBeCalled();
     $product->addVariant($productVariant)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $sharedStorage->set('variant', $productVariant)->shouldBeCalled();
     $this->theProductHasVariantPricedAt($product, 'Han Solo Mug', '2500');
 }
示例#27
0
 /**
  * @Given the customer :customer placed an order :orderNumber
  */
 public function theCustomerPlacedAnOrder(CustomerInterface $customer, $orderNumber)
 {
     /** @var OrderInterface $order */
     $order = $this->orderFactory->createNew();
     $order->setCustomer($customer);
     $order->setNumber($orderNumber);
     $order->setChannel($this->sharedStorage->get('channel'));
     $order->setCurrency($this->sharedStorage->get('currency'));
     $this->sharedStorage->set('order', $order);
     $this->orderRepository->add($order);
 }
示例#28
0
 /**
  * @Given the store has 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);
 }
示例#29
0
 function it_creates_customers_order(CustomerInterface $customer, ChannelInterface $channel, CurrencyInterface $currency, FactoryInterface $orderFactory, OrderInterface $order, OrderRepositoryInterface $orderRepository, SharedStorageInterface $sharedStorage)
 {
     $sharedStorage->get('channel')->willReturn($channel);
     $sharedStorage->get('currency')->willReturn($currency);
     $orderFactory->createNew()->willReturn($order);
     $order->setCustomer($customer)->shouldBeCalled();
     $order->setChannel($channel)->shouldBeCalled();
     $order->setCurrency($currency)->shouldBeCalled();
     $order->setNumber('#00000022')->shouldBeCalled();
     $orderRepository->add($order)->shouldBeCalled();
     $sharedStorage->set('order', $order)->shouldBeCalled();
     $this->theCustomerPlacedAnOrder($customer, '#00000022');
 }
示例#30
0
 /**
  * @param string $email
  * @param string $password
  * @param bool $enabled
  * @param string|null $firstName
  * @param string|null $lastName
  */
 private function createCustomerWithUserAccount($email, $password, $enabled = true, $firstName = null, $lastName = 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);
     $customer->setUser($user);
     $this->sharedStorage->set('customer', $customer);
     $this->customerRepository->add($customer);
 }