コード例 #1
0
ファイル: SecurityContext.php プロジェクト: okwinza/Sylius
 /**
  * @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);
 }
コード例 #2
0
 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]);
 }
コード例 #3
0
 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');
 }
コード例 #4
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);
 }
コード例 #5
0
 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();
 }
コード例 #6
0
ファイル: ChannelContext.php プロジェクト: ahmadrabie/Sylius
 /**
  * @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);
 }
コード例 #7
0
ファイル: CheckoutContext.php プロジェクト: Spomky/Sylius
 /**
  * @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()));
 }
コード例 #8
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);
 }
コード例 #9
0
ファイル: ThemeContext.php プロジェクト: okwinza/Sylius
 /**
  * @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);
 }
コード例 #10
0
ファイル: LocaleContext.php プロジェクト: ahmadrabie/Sylius
 /**
  * @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);
 }
コード例 #11
0
ファイル: UserContext.php プロジェクト: andrew-pits/Sylius
 /**
  * @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);
 }
コード例 #12
0
 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();
 }
コード例 #13
0
ファイル: CurrencyContext.php プロジェクト: Spomky/Sylius
 /**
  * @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);
 }
コード例 #14
0
ファイル: ChannelContext.php プロジェクト: okwinza/Sylius
 /**
  * @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);
 }
コード例 #15
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');
 }
コード例 #16
0
ファイル: UserContextSpec.php プロジェクト: vikey89/Sylius
 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();
 }
コード例 #17
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']);
 }
コード例 #18
0
 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');
 }
コード例 #19
0
ファイル: ProductContext.php プロジェクト: Spomky/Sylius
 /**
  * @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);
 }
コード例 #20
0
ファイル: PromotionContextSpec.php プロジェクト: Mozan/Sylius
 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');
 }
コード例 #21
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);
 }
コード例 #22
0
ファイル: PaymentContext.php プロジェクト: Spomky/Sylius
 /**
  * @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);
 }
コード例 #23
0
 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);
 }
コード例 #24
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');
 }
コード例 #25
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);
 }
コード例 #26
0
ファイル: PaymentContext.php プロジェクト: vikey89/Sylius
 /**
  * @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);
 }
コード例 #27
0
ファイル: ShippingContext.php プロジェクト: Spomky/Sylius
 /**
  * @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);
 }
コード例 #28
0
 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);
 }
コード例 #29
0
ファイル: ShippingContext.php プロジェクト: dszwcz/Sylius
 /**
  * @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);
 }
コード例 #30
0
ファイル: UserContext.php プロジェクト: Mangetsu/Sylius
 /**
  * @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);
 }