/** * Assert that redirect from newCategory/oldProduct is correct to new product. * * @param InjectableFixture $product * @param InjectableFixture $initialProduct * @param Browser $browser * @param CatalogProductView $catalogProductView * @return void */ public function processAssert(InjectableFixture $product, InjectableFixture $initialProduct, Browser $browser, CatalogProductView $catalogProductView) { $category = $product->getDataFieldConfig('category_ids')['source']->getProductCategory(); $productUrl = $_ENV['app_frontend_url'] . $category->getUrlKey() . '/' . $initialProduct->getUrlKey() . '.html'; $browser->open($productUrl); \PHPUnit_Framework_Assert::assertEquals($catalogProductView->getViewBlock()->getProductName(), strtoupper($product->getName())); }
/** * Assertion that tier prices are displayed correctly. * * @param Browser $browser * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @return void */ public function processAssert(Browser $browser, CatalogProductView $catalogProductView, InjectableFixture $product) { //Open product view page $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); //Process assertions $this->assertPrice($product, $catalogProductView->getViewBlock()); }
/** * Assertion that the product is correctly displayed in cart. * * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @param Browser $browser * @param CheckoutCart $checkoutCart * @return void */ public function processAssert(CatalogProductView $catalogProductView, InjectableFixture $product, Browser $browser, CheckoutCart $checkoutCart) { // Add product to cart $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); // Check price $this->assertOnShoppingCart($product, $checkoutCart); }
/** * Assertion that commodity options are displayed correctly. * * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @param Browser $browser * @return void */ public function processAssert(CatalogProductView $catalogProductView, InjectableFixture $product, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $fixtureCustomOptions = $this->prepareOptions($product); $formCustomOptions = $catalogProductView->getViewBlock()->getOptions($product)['custom_options']; $error = $this->verifyData($fixtureCustomOptions, $formCustomOptions); \PHPUnit_Framework_Assert::assertEmpty($error, $error); }
/** * Check whether there is an opportunity to compare products using given attribute. * * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @param BrowserInterface $browser * @param CatalogProductView $catalogProductView * @param CatalogProductCompare $catalogProductCompare * @return void */ public function processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, BrowserInterface $browser, CatalogProductView $catalogProductView, CatalogProductCompare $catalogProductCompare) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->clickAddToCompare(); $catalogProductCompare->open(); $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertTrue($catalogProductCompare->getCompareProductsBlock()->isAttributeVisible($label), 'Attribute is absent on product compare page.'); }
/** * Assertion that the product is correctly displayed in cart. * * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @param Browser $browser * @param CheckoutCart $checkoutCart * @return void */ public function processAssert(CatalogProductView $catalogProductView, InjectableFixture $product, Browser $browser, CheckoutCart $checkoutCart) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); $checkoutData = $product->getCheckoutData(); $price = $checkoutCart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price'); \PHPUnit_Framework_Assert::assertEquals($checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.'); }
/** * Assert that displayed product data on product page(front-end) equals passed from fixture: * 1. Product Name * 2. Price * 3. Special price * 4. SKU * 5. Description * 6. Short Description * * @param Browser $browser * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @return void */ public function processAssert(Browser $browser, CatalogProductView $catalogProductView, InjectableFixture $product) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->product = $product; $this->productView = $catalogProductView->getViewBlock(); $this->catalogProductView = $catalogProductView; $errors = $this->verify(); \PHPUnit_Framework_Assert::assertEmpty($errors, "\nFound the following errors:\n" . implode(" \n", $errors)); }
/** * Assert that product can be added to active gift registry from shopping cart. * * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param InjectableFixture $product * @param GiftRegistry $giftRegistry * @param GiftRegistryItems $giftRegistryItems * @param BrowserInterface $browser * @return void */ public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product, GiftRegistry $giftRegistry, GiftRegistryItems $giftRegistryItems, BrowserInterface $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); $checkoutCart->getGiftRegistryBlock()->addToGiftRegistry($giftRegistry); \PHPUnit_Framework_Assert::assertTrue($giftRegistryItems->getGiftRegistryItemsBlock()->isProductInGrid($product), "Product can not be added to active gift registry '{$giftRegistry->getTitle()}' from shopping cart."); }
/** * Assert that add view review links are present on product page. * * @param Browser $browser * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @param Review $review * @return void */ public function processAssert(Browser $browser, CatalogProductView $catalogProductView, InjectableFixture $product, Review $review) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); // Verify add review link \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getReviewViewBlock()->getAddReviewLink()->isVisible(), 'Add review link is not visible on product page.'); // Verify view review link $viewReviewLink = $catalogProductView->getReviewViewBlock()->getViewReviewLink($review); \PHPUnit_Framework_Assert::assertTrue($viewReviewLink->isVisible(), 'View review link is not visible on product page.'); \PHPUnit_Framework_Assert::assertContains('1', $viewReviewLink->getText(), 'There is more than 1 approved review.'); }
/** * Assert that product duplicate is not displayed on front-end. * * @param InjectableFixture $product * @param Browser $browser * @param CatalogProductView $catalogProductView * @return void */ public function processAssert(InjectableFixture $product, Browser $browser, CatalogProductView $catalogProductView) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '-1' . '.html'); \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->isVisible(), 'Duplicate Product is displayed on frontend.'); }
/** * Assert that In Stock status is displayed on product page. * * @param CatalogProductView $catalogProductView * @param Browser $browser * @param InjectableFixture $product * @return void */ public function processAssert(CatalogProductView $catalogProductView, Browser $browser, InjectableFixture $product) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertEquals(self::STOCK_AVAILABILITY, $catalogProductView->getViewBlock()->getStockAvailability($product), 'Control "' . self::STOCK_AVAILABILITY . '" is not visible.'); }
/** * Assert that 'Add to Cart' button is absent on product page. * * @param CatalogProductView $catalogProductView * @param InjectableFixture $product * @param Browser $browser * @return void */ public function processAssert(CatalogProductView $catalogProductView, InjectableFixture $product, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->checkAddToCartButton(), 'Add to Cart button is present on product page'); }
/** * Check whether html tags are using in attribute value. * Checked tag structure <b><i>atttribute_default_value</p></i></b> * * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @param CatalogProductView $catalogProductView * @param BrowserInterface $browser * @throws \Exception * @return void */ public function processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, CatalogProductView $catalogProductView, BrowserInterface $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getAdditionalInformationBlock()->hasHtmlTagInAttributeValue($attribute), 'Attribute is not visible with HTML tags on frontend.'); }
/** * Assert that video is absent on product page on Store front. * * @param BrowserInterface $browser * @param CatalogProductView $catalogProductView * @param InjectableFixture $initialProduct */ public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, InjectableFixture $initialProduct) { $browser->open($_ENV['app_frontend_url'] . $initialProduct->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->isGalleryVisible(); \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->isGalleryVisible(), 'Product video is displayed on product view when it should not.'); }
/** * Add product to compare list. * * @param InjectableFixture $product * @return void */ protected function addProduct(InjectableFixture $product) { $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->catalogProductView->getViewBlock()->clickAddToCompare(); }
/** * Add product to multiple wish list. * * @param InjectableFixture $product * @param bool $isDuplicate [optional] * @return void */ protected function addToMultipleWishlist(InjectableFixture $product, $isDuplicate = false) { $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->catalogProductView->getViewBlock()->fillOptions($product); $checkoutData = $product->getCheckoutData(); if (isset($checkoutData['qty'])) { $qty = $isDuplicate ? $checkoutData['qty'] / 2 : $checkoutData['qty']; $this->catalogProductView->getViewBlock()->setQty($qty); } $this->catalogProductView->getMultipleWishlistViewBlock()->addToMultipleWishlist($this->multipleWishlist); }
/** * Assert that product can not be added to inactive gift registry from shopping cart. * * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param InjectableFixture $product * @param GiftRegistry $giftRegistry * @param BrowserInterface $browser * @return void */ public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product, GiftRegistry $giftRegistry, BrowserInterface $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getGiftRegistryBlock()->isGiftRegistryAvailable($giftRegistry), "Product can be added to inactive gift registry '{$giftRegistry->getTitle()}' from shopping cart."); }
/** * Verify product displaying on frontend. * * @param InjectableFixture $product * @return array */ protected function isNotDisplayingOnFrontendAssert(InjectableFixture $product) { $errors = []; //Check that product is not available by url $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); if ($this->catalogProductView->getViewBlock()->isVisible()) { $errors[] = '- product view block is visible in product page.'; } //Check that product can't be found $this->cmsIndex->open()->getSearchBlock()->search($product->getSku()); if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product)) { $errors[] = '- successful product search.'; } //Check that product is not available in category page $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $this->category->getName(); $this->cmsIndex->open()->getTopmenu()->selectCategory($categoryName); $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product); $bottomToolBar = $this->catalogCategoryView->getBottomToolbar(); while (!$isProductVisible && $bottomToolBar->nextPage()) { $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product); } if ($isProductVisible) { $errors[] = "- product with name '{$product->getName()}' is found in this category."; } return $errors; }
/** * Check whether the attribute is visible on the frontend. * * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @param CatalogProductView $catalogProductView * @param BrowserInterface $browser * @return void */ public function processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, CatalogProductView $catalogProductView, BrowserInterface $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertTrue(in_array($attribute->getFrontendLabel(), $catalogProductView->getAdditionalInformationBlock()->getAttributeLabels()), 'Attribute is not visible on product page in additional info block on frontend.'); }