/** * @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); }
function it_throws_an_exception_if_a_product_exists_when_it_should_not(SharedStorageInterface $sharedStorage, IndexPageInterface $adminProductIndexPage, ProductInterface $product) { $sharedStorage->get('product')->willReturn($product); $adminProductIndexPage->open()->shouldBeCalled(); $adminProductIndexPage->isThereProduct($product)->willReturn(true); $this->shouldThrow(NotEqualException::class)->during('productShouldNotExist', [$product]); }
function it_throws_runtime_exception_if_cannot_find_last_order_for_given_customer(SharedStorageInterface $sharedStorage, OrderRepositoryInterface $orderRepository, UserInterface $user, CustomerInterface $customer) { $sharedStorage->get('user')->willReturn($user); $user->getCustomer()->willReturn($customer); $orderRepository->findByCustomer($customer)->willReturn([]); $this->shouldThrow(\RuntimeException::class)->during('iTryToPayAgain'); }
/** * @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); }
function it_sets_default_channel_in_the_shared_storage(SharedStorageInterface $sharedStorage, DefaultStoreDataInterface $defaultFranceChannelFactory, ChannelInterface $channel, ZoneInterface $zone) { $defaultData = ['channel' => $channel, 'zone' => $zone]; $defaultFranceChannelFactory->create()->willReturn($defaultData); $sharedStorage->setClipboard($defaultData)->shouldBeCalled(); $this->thatStoreIsOperatingOnASingleChannel(); }
/** * @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); }
/** * @Then I should see the thank you page */ public function iShouldSeeTheThankYouPage() { $user = $this->sharedStorage->getCurrentResource('user'); $customer = $user->getCustomer(); $thankYouPage = $this->getPage('Checkout\\CheckoutThankYouPage'); $thankYouPage->assertRoute(); $this->assertSession()->elementTextContains('css', '#thanks', sprintf('Thank you %s', $customer->getFullName())); }
/** * @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); }
/** * @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 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); }
/** * @Given there is user :email identified by :password, with :country as shipping country */ public function thereIsUserWithShippingCountry($email, $password, $country) { $customer = $this->createCustomer(); $user = $this->createUser($customer, $email, $password); $customer->setShippingAddress($this->createAddress($customer->getFirstName(), $customer->getLastName(), $country)); $this->sharedStorage->setCurrentResource('user', $user); $this->userRepository->add($user); }
function it_checks_if_customer_still_exists(ShowPageInterface $customerShowPage, SharedStorageInterface $sharedStorage, CustomerInterface $customer, UserInterface $user) { $sharedStorage->get('deleted_user')->shouldBeCalled()->willReturn($user); $user->getCustomer()->willReturn($customer); $customer->getId()->willReturn(1); $customerShowPage->open(['id' => 1])->shouldBeCalled(); $customerShowPage->isRegistered()->willReturn(false); $this->customerShouldStillExist(); }
/** * @Given default currency is :currencyCode */ public function defaultCurrencyIs($currencyCode) { $currency = $this->currencyFactory->createNew(); $currency->setCode($currencyCode); $currency->setExchangeRate(1.0); $channel = $this->sharedStorage->getCurrentResource('channel'); $channel->setDefaultCurrency($currency); $this->currencyRepository->add($currency); }
/** * @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); }
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'); }
function it_checks_if_account_was_deleted(SharedStorageInterface $sharedStorage, UserInterface $user, CustomerInterface $customer, CustomerShowPage $customerShowPage) { $sharedStorage->get('deleted_user')->willReturn($user); $user->getCustomer()->willReturn($customer); $customer->getId()->willReturn(1); $customerShowPage->open(['id' => 1])->shouldBeCalled(); $customerShowPage->isRegistered()->willReturn(false); $this->accountShouldBeDeleted(); }
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']); }
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'); }
/** * @Given catalog has a product :productName priced at $:price */ public function catalogHasAProductPricedAt($productName, $price) { $product = $this->productFactory->createNew(); $product->setName($productName); $product->setPrice((int) $price); $product->setDescription('Awesome star wars mug'); $channel = $this->sharedStorage->getCurrentResource('channel'); $product->addChannel($channel); $this->productRepository->add($product); }
function it_creates_fixed_discount_promotion_for_cart_with_specified_quantity(ActionFactoryInterface $actionFactory, ActionInterface $action, ObjectManager $objectManager, PromotionInterface $promotion, RuleFactoryInterface $ruleFactory, RuleInterface $rule, SharedStorageInterface $sharedStorage) { $sharedStorage->get('promotion')->willReturn($promotion); $actionFactory->createFixedDiscount(1000)->willReturn($action); $promotion->addAction($action)->shouldBeCalled(); $ruleFactory->createCartQuantity(5)->willReturn($rule); $promotion->addRule($rule)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->itGivesFixedDiscountToEveryOrderWithQuantityAtLeast($promotion, 1000, '5'); }
/** * @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); }
/** * @Given store allows paying offline */ public function storeAllowsPayingOffline() { $paymentMethod = $this->paymentMethodFactory->createNew(); $paymentMethod->setCode('PM1'); $paymentMethod->setGateway('dummy'); $paymentMethod->setName('Offline'); $paymentMethod->setDescription('Offline payment method'); $channel = $this->sharedStorage->getCurrentResource('channel'); $channel->addPaymentMethod($paymentMethod); $this->paymentMethodRepository->add($paymentMethod); }
function it_creates_a_review_for_a_given_product(SharedStorageInterface $sharedStorage, FactoryInterface $reviewFactory, RepositoryInterface $productReviewRepository, ProductInterface $product, ReviewInterface $review) { $sharedStorage->get('product')->willReturn($product); $reviewFactory->createNew()->willReturn($review); $review->setTitle('title')->shouldBeCalled(); $review->setRating(5)->shouldBeCalled(); $review->setReviewSubject($product)->shouldBeCalled(); $product->addReview($review)->shouldBeCalled(); $productReviewRepository->add($review); $this->productHasAReview($product); }
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'); }
/** * @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); }
/** * @Given the store allows paying :paymentMethodName */ public function storeAllowsPaying($paymentMethodName) { $paymentMethod = $this->paymentMethodFactory->createNew(); $paymentMethod->setCode('PM_' . $paymentMethodName); $paymentMethod->setName(ucfirst($paymentMethodName)); $paymentMethod->setGateway($this->paymentMethodNameToGatewayConverter->convert($paymentMethodName)); $paymentMethod->setDescription('Payment method'); $channel = $this->sharedStorage->get('channel'); $channel->addPaymentMethod($paymentMethod); $this->paymentMethodRepository->add($paymentMethod); }
/** * @Given store has free shipping method */ public function storeHasFreeShippingMethod() { $zone = $this->sharedStorage->getCurrentResource('zone'); $shippingMethod = $this->shippingMethodFactory->createNew(); $shippingMethod->setCode('SM1'); $shippingMethod->setName('Free'); $shippingMethod->setCurrentLocale('FR'); $shippingMethod->setConfiguration(array('amount' => 0)); $shippingMethod->setCalculator(DefaultCalculators::PER_ITEM_RATE); $shippingMethod->setZone($zone); $this->shippingMethodRepository->add($shippingMethod); }
function it_adds_single_item_by_customer(FactoryInterface $orderItemFactory, OrderInterface $order, OrderItemInterface $item, OrderItemQuantityModifierInterface $itemQuantityModifier, ProductInterface $product, SharedStorageInterface $sharedStorage, ProductVariantInterface $variant, ObjectManager $objectManager) { $sharedStorage->get('order')->willReturn($order); $orderItemFactory->createNew()->willReturn($item); $product->getMasterVariant()->willReturn($variant); $product->getPrice()->willReturn(1234); $itemQuantityModifier->modify($item, 1)->shouldBeCalled(); $item->setVariant($variant)->shouldBeCalled(); $item->setUnitPrice(1234)->shouldBeCalled(); $order->addItem($item)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->theCustomerBoughtSingle($product); }
/** * @param string $name * @param string $locale * @param array $configuration * @param string $calculator * @param ZoneInterface|null $zone */ private function createShippingMethod($name, $locale = 'en', $configuration = ['amount' => 0], $calculator = DefaultCalculators::FLAT_RATE, $zone = null) { if (null === $zone) { $zone = $this->sharedStorage->getCurrentResource('zone'); } $shippingMethod = $this->shippingMethodFactory->createNew(); $shippingMethod->setCode($this->getCodeFromName($name)); $shippingMethod->setName($name); $shippingMethod->setCurrentLocale($locale); $shippingMethod->setConfiguration($configuration); $shippingMethod->setCalculator($calculator); $shippingMethod->setZone($zone); $this->shippingMethodRepository->add($shippingMethod); }
/** * @Given there is user :email identified by :password */ public function thereIsUserIdentifiedBy($email, $password) { /** @var UserInterface $user */ $user = $this->userFactory->createNew(); $customer = $this->customerFactory->createNew(); $customer->setFirstName('John'); $customer->setLastName('Doe'); $user->setCustomer($customer); $user->setUsername('John Doe'); $user->setEmail($email); $user->setPlainPassword($password); $user->addRole('ROLE_USER'); $this->sharedStorage->setCurrentResource('user', $user); $this->userRepository->add($user); }