/** * @return NodeElement[] * * @throws \InvalidArgumentException */ private function getProductAttributes() { $attributes = $this->showPage->getAttributes(); Assert::notNull($attributes, 'The product has no attributes.'); return $attributes; }
/** * @Then I should see the product attribute :attributeName with value :AttributeValue */ public function iShouldSeeTheProductAttributeWithValue($attributeName, $AttributeValue) { Assert::true($this->showPage->hasAttributeWithValue($attributeName, $AttributeValue), sprintf('Product should have attribute %s with value %s, but it does not.', $attributeName, $AttributeValue)); }
/** * @Given I have :product with :productOption :productOptionValue in the cart * @When I add :product with :productOption :productOptionValue to the cart */ public function iAddThisProductWithToTheCart(ProductInterface $product, ProductOptionInterface $productOption, $productOptionValue) { $this->productShowPage->open(['slug' => $product->getSlug()]); $this->productShowPage->addToCartWithOption($productOption, $productOptionValue); }
/** * @Then I should see a main image */ public function iShouldSeeAMainImage() { Assert::true($this->showPage->isMainImageDisplayed(), 'The main image should have been displayed.'); }
/** * @param string $productName * @param string $productAssociationName * * @throws \InvalidArgumentException */ private function assertIsProductIsInAssociation($productName, $productAssociationName) { Assert::true($this->showPage->hasProductInAssociation($productName, $productAssociationName), sprintf('There should be an associated product "%s" under association "%s" but it does not.', $productName, $productAssociationName)); }
/** * @Given I have :quantity products :product in the cart * @When I add :quantity products :product to the cart */ public function iAddProductsToTheCart(ProductInterface $product, $quantity) { $this->productShowPage->open(['product' => $product]); $this->productShowPage->addToCartWithQuantity($quantity); $this->sharedStorage->set('product', $product); }
/** * @Then /^I should not be notified that (this product) does not have sufficient stock$/ */ public function iShouldNotBeNotifiedThatThisProductDoesNotHaveSufficientStock(ProductInterface $product) { Assert::false($this->showPage->hasProductOutOfStockValidationMessage($product), sprintf('I should see validation message for %s product', $product->getName())); }
/** * @Then I should see the product price :price */ public function iShouldSeeTheProductPrice($price) { Assert::same($price, $this->showPage->getPrice(), 'Product should have price %2$s, but it has %s'); }
/** * @Then I should not be able to access product :product */ public function iShouldNotBeAbleToAccessProduct(ProductInterface $product) { $this->productShowPage->tryToOpen(['product' => $product]); expect($this->productShowPage->isOpen(['product' => $product]))->toBe(false); }
function it_throws_an_exception_if_i_am_able_to_access_product_page_when_i_should_not(ShowPageInterface $productShowPage, ProductInterface $product) { $productShowPage->tryToOpen(['product' => $product])->shouldBeCalled(); $productShowPage->isOpen(['product' => $product])->willReturn(true); $this->shouldThrow(NotEqualException::class)->during('iShouldNotBeAbleToAccessProduct', [$product]); }