Example #1
0
 /**
  * Check if ordered product is in grid
  *
  * @param CatalogProductSimple $product
  * @return bool
  */
 public function isProductVisible(CatalogProductSimple $product)
 {
     $filter = [$product->getName(), $product->getPrice(), $product->getCheckoutData()['qty']];
     $rows = [];
     foreach ($filter as $value) {
         $rows[] = sprintf($this->rowTemplate, $value);
     }
     $location = $this->location . '[' . implode(' and ', $rows) . ']';
     return $this->_rootElement->find($location, Locator::SELECTOR_XPATH)->isVisible();
 }
Example #2
0
 /**
  * Check that product visible in grid
  *
  * @param CatalogProductSimple $product
  * @param string $carts
  * @return bool
  */
 public function isProductVisible(CatalogProductSimple $product, $carts)
 {
     $result = false;
     $productRowSelector = sprintf($this->productRow, $product->getName());
     $productPrice = sprintf($this->productPrice, $product->getPrice());
     $productRow = $this->_rootElement->find($productRowSelector, Locator::SELECTOR_XPATH);
     if ($productRow->isVisible()) {
         $result = $productRow->find($productPrice, Locator::SELECTOR_XPATH)->isVisible() && $productRow->find(sprintf($this->productCarts, $carts), Locator::SELECTOR_XPATH)->isVisible();
     }
     return $result;
 }
 /**
  * Assert data on the product view page
  *
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 protected function assertOnProductView(CatalogProductSimple $product, CatalogProductView $catalogProductView)
 {
     $viewBlock = $catalogProductView->getViewBlock();
     $price = $viewBlock->getPriceBlock()->getPrice();
     $name = $viewBlock->getProductName();
     $sku = $viewBlock->getProductSku();
     \PHPUnit_Framework_Assert::assertEquals($product->getName(), $name, 'Product name on product view page is not correct.');
     \PHPUnit_Framework_Assert::assertEquals($product->getSku(), $sku, 'Product sku on product view page is not correct.');
     if (isset($price['price_regular_price'])) {
         \PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $price['price_regular_price'], 'Product regular price on product view page is not correct.');
     }
     $priceComparing = false;
     if ($specialPrice = $product->getSpecialPrice()) {
         $priceComparing = $specialPrice;
     }
     if ($priceComparing && isset($price['price_special_price'])) {
         \PHPUnit_Framework_Assert::assertEquals(number_format($priceComparing, 2), $price['price_special_price'], 'Product special price on product view page is not correct.');
     }
 }