예제 #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 default tax zone is :zone
  */
 public function defaultTaxZoneIs(ZoneInterface $zone)
 {
     /** @var ChannelInterface $channel */
     $channel = $this->sharedStorage->get('channel');
     $channel->setDefaultTaxZone($zone);
     $this->objectManager->flush();
 }
예제 #3
0
 /**
  * @Given the store allows paying :paymentMethodName
  * @Given the store allows paying with :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->sharedStorage->set('payment_method', $paymentMethod);
     $this->paymentMethodRepository->add($paymentMethod);
 }
예제 #4
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);
 }
 /**
  * @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);
 }
예제 #6
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;
 }
예제 #7
0
 /**
  * @Given /^(this product) is available in "([^"]+)" size priced at ("[^"]+")$/
  */
 public function thisProductIsAvailableInSize(ProductInterface $product, $optionValueName, $price)
 {
     /** @var ProductVariantInterface $variant */
     $variant = $this->productVariantFactory->createNew();
     $optionValue = $this->sharedStorage->get(sprintf('%s_option_value', $optionValueName));
     $variant->addOption($optionValue);
     $variant->setPrice($price);
     $variant->setCode(sprintf("%s_%s", $product->getCode(), $optionValueName));
     $product->addVariant($variant);
     $this->objectManager->flush();
 }
예제 #8
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);
 }
예제 #9
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;
 }
예제 #10
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;
 }
예제 #11
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);
 }
예제 #12
0
 /**
  * @param CustomerInterface $customer
  * @param string $number
  * @param ChannelInterface|null $channel
  * @param string|null $currencyCode
  * @param string|null $localeCode
  *
  * @return OrderInterface
  */
 private function createOrder(CustomerInterface $customer, $number = null, ChannelInterface $channel = null, $currencyCode = null, $localeCode = 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->setLocaleCode(null !== $localeCode ? $localeCode : $this->sharedStorage->get('locale')->getCode());
     $currencyCode = $currencyCode ? $currencyCode : $this->sharedStorage->get('currency')->getCode();
     $currency = $this->currencyRepository->findOneBy(['code' => $currencyCode]);
     $order->setCurrencyCode($currency->getCode());
     $order->setExchangeRate($currency->getExchangeRate());
     $order->complete();
     return $order;
 }
예제 #13
0
 /**
  * @param string $productName
  * @param int $price
  * @param string|null $date
  * @param ChannelInterface|null $channel
  *
  * @return ProductInterface
  */
 private function createProduct($productName, $price = 100, $date = null, ChannelInterface $channel = null)
 {
     /** @var ProductInterface $product */
     $product = $this->productFactory->createWithVariant();
     $product->setName($productName);
     $product->setCode(StringInflector::nameToUppercaseCode($productName));
     $product->setSlug($this->slugGenerator->generate($productName));
     $product->setCreatedAt(new \DateTime($date));
     /** @var ProductVariantInterface $productVariant */
     $productVariant = $this->defaultVariantResolver->getVariant($product);
     if (null === $channel && $this->sharedStorage->has('channel')) {
         $channel = $this->sharedStorage->get('channel');
     }
     if (null !== $channel) {
         $productVariant->addChannelPricing($this->createChannelPricingForChannel($price, $channel));
     }
     $productVariant->setCode($product->getCode());
     return $product;
 }
 /**
  * @Then this product should still exist in the product catalog
  */
 public function productShouldExistInTheProductCatalog()
 {
     $productId = $this->sharedStorage->get('product_id');
     $product = $this->productRepository->find($productId);
     Assert::notNull($product);
 }
예제 #15
0
 /**
  * @Then /^this variant should not exist in the product catalog$/
  */
 public function productVariantShouldNotExistInTheProductCatalog()
 {
     $productVariantId = $this->sharedStorage->get('product_variant_id');
     $productVariant = $this->productVariantRepository->find($productVariantId);
     Assert::null($productVariant);
 }
예제 #16
0
 /**
  * @Given his account was deleted
  */
 public function hisAccountWasDeleted()
 {
     $user = $this->sharedStorage->get('user');
     $this->userRepository->remove($user);
 }
예제 #17
0
 /**
  * @Then /^it should contain "([^"]+)"$/
  */
 public function itShouldContain($value)
 {
     $fullName = $this->sharedStorage->get('full_name');
     $this->addressBookIndexPage->addressOfContains($fullName, $value);
 }
예제 #18
0
 /**
  * @Then /^I should be notified that this (?:variant|product) is in use and cannot be deleted$/
  */
 public function iShouldBeNotifiedThatThisProductVariantIsInUseAndCannotBeDeleted()
 {
     Assert::isInstanceOf($this->sharedStorage->get('last_exception'), DBALException::class);
 }
예제 #19
0
 /**
  * @param PromotionInterface $promotion
  * @param int $discount
  * @param array $configuration
  * @param PromotionRuleInterface|null $rule
  * @param ChannelInterface|null $channel
  */
 private function createFixedPromotion(PromotionInterface $promotion, $discount, array $configuration = [], PromotionRuleInterface $rule = null, ChannelInterface $channel = null)
 {
     $channelCode = null !== $channel ? $channel->getCode() : $this->sharedStorage->get('channel')->getCode();
     $this->persistPromotion($promotion, $this->actionFactory->createFixedDiscount($discount, $channelCode), $configuration, $rule);
 }
 /**
  * @Then I should be notified that it is in use and cannot be deleted
  */
 public function iShouldBeNotifiedOfFailure()
 {
     Assert::isInstanceOf($this->sharedStorage->get('last_exception'), ForeignKeyConstraintViolationException::class);
 }
예제 #21
0
 /**
  * @Transform /^(he|his|she|her|their|the customer of my account)$/
  */
 public function getLastCustomer()
 {
     return $this->sharedStorage->get('customer');
 }
예제 #22
0
 /**
  * @Given I want to change my password
  */
 public function iWantToChangeMyPassword()
 {
     $customer = $this->sharedStorage->get('customer');
     $this->updatePage->open(['id' => $customer->getId()]);
 }
예제 #23
0
 /**
  * @Given the customer chose :currencyCode currency
  * @Given I chose :currencyCode currency
  */
 public function theCustomerChoseTheCurrency($currencyCode)
 {
     $this->currencyStorage->set($this->sharedStorage->get('channel'), $currencyCode);
 }
예제 #24
0
 /**
  * @Given /^(this product) also has review rated (\d+) which is rejected$/
  */
 public function itAlsoHasReviewRatedWhichIsRejected(ProductInterface $product, $rate)
 {
     $customer = $this->sharedStorage->get('customer');
     $review = $this->createProductReview($product, 'Title', $rate, 'Comment', $customer, ProductReviewTransitions::TRANSITION_REJECT);
     $this->productReviewRepository->add($review);
 }
예제 #25
0
 /**
  * @Given /^the store has "([^"]+)" shipping method with ("[^"]+") fee not assigned to any channel$/
  */
 public function storeHasShippingMethodWithFeeNotAssignedToAnyChannel($shippingMethodName, $fee)
 {
     $channel = $this->sharedStorage->get('channel');
     $configuration = $this->getConfigurationByChannels([$channel], $fee);
     $this->saveShippingMethod($this->shippingMethodExampleFactory->create(['name' => $shippingMethodName, 'enabled' => true, 'calculator' => ['type' => DefaultCalculators::FLAT_RATE, 'configuration' => $configuration], 'channels' => []]));
 }
예제 #26
0
 /**
  * @Transform /^(?:this|that|the) ([^"]+)$/
  */
 public function getResource($resource)
 {
     return $this->sharedStorage->get(StringInflector::nameToCode($resource));
 }
예제 #27
0
 /**
  * @Then adjustments of this order should not exist
  */
 public function adjustmentShouldNotExistInTheRegistry()
 {
     $adjustments = $this->sharedStorage->get('deleted_adjustments');
     $adjustments = $this->adjustmentRepository->findBy(['id' => $adjustments]);
     Assert::same($adjustments, []);
 }
예제 #28
0
 /**
  * @Then the customer with this email should still exist
  */
 public function customerShouldStillExist()
 {
     $deletedUser = $this->sharedStorage->get('deleted_user');
     $this->customerShowPage->open(['id' => $deletedUser->getCustomer()->getId()]);
     Assert::false($this->customerShowPage->isRegistered());
 }
예제 #29
0
 /**
  * @Then my order's billing address should be to :fullName
  */
 public function iShouldSeeThisBillingAddressAsBillingAddress($fullName)
 {
     $address = $this->sharedStorage->get('billing_address_' . StringInflector::nameToLowercaseCode($fullName));
     Assert::true($this->completePage->hasBillingAddress($address), 'Billing address is improper.');
 }
예제 #30
0
 /**
  * @When I use the verification link from the first email to verify
  */
 public function iUseVerificationLinkFromFirstEmailToVerify()
 {
     $token = $this->sharedStorage->get('verification_token');
     $this->verificationPage->verifyAccount($token);
 }