/** * Verify displayed product name on product page(front-end) equals passed from fixture * * @return string|null */ protected function verifyName() { $fixtureProductName = $this->product->getName(); $formProductName = $this->productView->getProductName(); if ($fixtureProductName == $formProductName) { return null; } return "Displayed product name on product page(front-end) not equals passed from fixture. " . "Actual: {$formProductName}, expected: {$fixtureProductName}."; }
/** * Assert that products generated during configurable product creation - are not visible on frontend(by default). * * @param CatalogSearchResult $catalogSearchResult * @param CmsIndex $cmsIndex * @param ConfigurableProduct $product * @return void */ public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, ConfigurableProduct $product) { $configurableAttributesData = $product->getConfigurableAttributesData(); $errors = []; $cmsIndex->open(); foreach ($configurableAttributesData['matrix'] as $variation) { $cmsIndex->getSearchBlock()->search($variation['sku']); $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($variation['name']); while (!$isVisibleProduct && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); } if ($isVisibleProduct) { $errors[] = sprintf("\nChild product with sku: \"%s\" is visible on frontend(by default).", $variation['sku']); } } \PHPUnit_Framework_Assert::assertEmpty($errors, implode(' ', $errors)); }
/** * Assert configurable product on Frontend * * @param ConfigurableProduct $product * @return void */ protected function assertOnFrontend(ConfigurableProduct $product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.'); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $productListBlock->openProductViewPage($product->getName()); $this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.'); $price = $product->getProductPrice(); $blockPrice = $productViewBlock->getProductPrice(); $this->assertEquals(number_format($price, 2), number_format($blockPrice['price_regular_price'], 2), 'Product price does not correspond to specified.'); $this->assertTrue($productViewBlock->verifyProductOptions($product), 'Added configurable options are absent'); }
/** * Assert configurable product on Frontend * * @param ConfigurableProduct $product * @return void */ protected function assertOnFrontend(ConfigurableProduct $product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.'); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $productListBlock->openProductViewPage($product->getName()); $this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.'); $price = $product->getProductPrice(); $priceOnPage = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals(number_format($price, 2), number_format($priceOnPage, 2), 'Product price does not correspond to specified.'); $pageOptions = $productViewBlock->getOptions($product); $configurableOptions = []; foreach ($pageOptions['configurable_options'] as $attribute) { $configurableOption = []; foreach ($attribute['options'] as $option) { $configurableOption[] = $option['title']; } $configurableOptions[$attribute['title']] = $configurableOption; } $this->assertEquals($product->getConfigurableOptions(), $configurableOptions); }