Example #1
0
 /**
  * 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);
 }
 /**
  * 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');
 }