/** * @Then I should be on :product product detailed page * @Then I should still be on product :product page */ public function iShouldBeOnProductDetailedPage(ProductInterface $product) { Assert::true($this->showPage->isOpen(['slug' => $product->getSlug()]), sprintf('Product %s show page should be open, but it does not.', $product->getName())); }
/** * @param ProductInterface $product * * @return NodeElement */ private function getProductRowElement(ProductInterface $product) { return $this->getElement('product_row', ['%name%' => $product->getName()]); }
/** * @Then /^(this product) should no longer have price for channel "([^"]+)"$/ */ public function thisProductShouldNoLongerHavePriceForChannel(ProductInterface $product, $channelName) { $this->updateSimpleProductPage->open(['id' => $product->getId()]); try { $this->updateSimpleProductPage->getPriceForChannel($channelName); } catch (ElementNotFoundException $exception) { return; } throw new \Exception(sprintf('Product "%s" should not have price defined for channel "%s".', $product->getName(), $channelName)); }
/** * @Then /^(product "[^"]+") should not have a "([^"]+)" attribute$/ */ public function productShouldNotHaveAttribute(ProductInterface $product, $attribute) { $this->updateSimpleProductPage->open(['id' => $product->getId()]); Assert::false($this->updateSimpleProductPage->hasAttribute($attribute), sprintf('Product "%s" should not have attribute "%s" but it does.', $product->getName(), $attribute)); }
/** * {@inheritdoc] */ public function hasProductOutOfStockValidationMessage(ProductInterface $product) { $message = sprintf('%s does not have sufficient stock.', $product->getName()); try { return $this->getElement('validation_errors')->getText() === $message; } catch (ElementNotFoundException $exception) { return false; } }
/** * @Then /^there should be no reviews of (this product)$/ */ public function thereAreNoProductReviews(ProductInterface $product) { $this->productReviewIndexPage->open(); Assert::false($this->productReviewIndexPage->isSingleResourceOnPage(['reviewSubject' => $product->getName()]), sprintf('There should be no reviews of %s.', $product->getName())); }
/** * @Given /^(product "[^"]+") price should not be decreased$/ */ public function productPriceShouldNotBeDecreased(ProductInterface $product) { $this->cartSummaryPage->open(); expect($this->cartSummaryPage->isItemDiscounted($product->getName()))->toBe(false); }
function it_throws_exception_if_discount_price_is_present_on_the_page_but_should_not(CartSummaryPageInterface $cartSummaryPage, ProductInterface $product) { $cartSummaryPage->open()->shouldBeCalled(); $product->getName()->willReturn('Test product'); $cartSummaryPage->isItemDiscounted('Test product')->willReturn(true); $this->shouldThrow(new FailureException('Expected <value>false</value>, but got <value>true</value>.'))->during('productPriceShouldNotBeDecreased', [$product]); }
/** * @Given /^(this product) is available in "([^"]+)" ([^"]+) priced at ("[^"]+")$/ */ public function thisProductIsAvailableInSize(ProductInterface $product, $optionValueName, $optionName, $price) { /** @var ProductVariantInterface $variant */ $variant = $this->productVariantFactory->createNew(); $optionValue = $this->sharedStorage->get(sprintf('%s_option_%s_value', $optionValueName, $optionName)); $variant->addOptionValue($optionValue); $variant->addChannelPricing($this->createChannelPricingForChannel($price, $this->sharedStorage->get('channel'))); $variant->setCode(sprintf("%s_%s", $product->getCode(), $optionValueName)); $variant->setName($product->getName()); $product->addVariant($variant); $this->objectManager->flush(); }