/** * @Given the store has a product :productName * @Given the store has a :productName product * @Given /^the store has a product "([^"]+)" priced at ("[^"]+")$/ */ public function storeHasAProductPricedAt($productName, $price = 0) { $product = $this->createProduct($productName, $price); $product->setDescription('Awesome ' . $productName); if ($this->sharedStorage->has('channel')) { $channel = $this->sharedStorage->get('channel'); $product->addChannel($channel); } $this->saveProduct($product); }
/** * @param string $name * @param string|null $code * @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, 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->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; $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createSimpleProductPage, $this->createConfigurableProductPage, $this->updateSimpleProductPage, $this->updateConfigurableProductPage], $product); Assert::true($currentPage->checkValidationMessageFor($element, $message), sprintf('Product %s should be required.', $element)); }