/**
  * Check that block Recently Viewed contains product on category page
  *
  * @param CatalogProductSimple $productSimple
  * @param Category $category
  * @return void
  */
 protected function checkRecentlyViewedBlockOnCategory(CatalogProductSimple $productSimple, Category $category)
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $products = $this->catalogCategoryView->getViewBlock()->getProductsFromRecentlyViewedBlock();
     \PHPUnit_Framework_Assert::assertTrue(in_array($productSimple->getName(), $products), 'Product' . $productSimple->getName() . ' is absent on Recently Viewed block on Category page.');
 }
 /**
  * Assert that product is displayed in related products section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView)
 {
     $categoryName = $product1->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getRelatedProductBlock()->isRelatedProductVisible($product2->getName()), 'Product \'' . $product2->getName() . '\' is absent in related products.');
 }
 /**
  * Assert that product is not displayed in up-sell section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView)
 {
     $categoryName = $product1->getCategoryIds()[0]['name'];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->isUpsellProductVisible($product2->getName()), 'Product \'' . $product2->getName() . '\' is exist in up-sells products.');
 }
 /**
  * "Add to cart" button is display on Product page
  *
  * @return void
  */
 protected function addToCardPresentOnProduct()
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($this->product->getCategoryIds()[0]);
     $this->catalogCategoryView->getListProductBlock()->openProductViewPage($this->product->getName());
     \PHPUnit_Framework_Assert::assertTrue($this->catalogProductView->getViewBlock()->checkAddToCardButton(), "Button 'Add to Card' is absent on Product page.");
 }
示例#5
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();
 }
 /**
  * Assert that products are displayed in up-sell section.
  *
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @param InjectableFixture[]|null $promotedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, CatalogProductSimple $product, array $promotedProducts = null)
 {
     if (!$promotedProducts) {
         $promotedProducts = $product->hasData('up_sell_products') ? $product->getDataFieldConfig('up_sell_products')['source']->getProducts() : [];
     }
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     foreach ($promotedProducts as $promotedProduct) {
         \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getUpsellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is absent in up-sells products of a product \'' . $product->getName() . '\'.');
     }
 }
 /**
  * Assert that product is displayed in cross-sell section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart)
 {
     $categoryName = $product1->getCategoryIds()[0];
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     $catalogProductView->getViewBlock()->addToCart($product1);
     \PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCrosssellBlock()->verifyProductCrosssell($product2), 'Product \'' . $product2->getName() . '\' is absent in cross-sell section.');
 }
示例#8
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;
 }
 /**
  * Login with each provided customer and get product prices
  *
  * @param CatalogProductSimple $product
  * @param array $customers
  * @return array
  */
 protected function getPricesForCustomers(CatalogProductSimple $product, $customers)
 {
     $prices = [];
     foreach ($customers as $customer) {
         $this->loginCustomer($customer);
         $productName = $product->getName();
         $this->openCategory($product);
         $actualPrices = [];
         $actualPrices = $this->getCategoryPrice($productName, $actualPrices);
         $this->catalogCategoryView->getListProductBlock()->openProductViewPage($productName);
         $actualPrices = $this->addToCart($product, $actualPrices);
         $actualPrices = $this->getCartPrice($product, $actualPrices);
         $prices[] = $actualPrices;
         $this->clearShoppingCart();
     }
     return $prices;
 }
 /**
  * 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.');
     }
 }
 /**
  * Assert that product quantity in the mini shopping cart is equals to expected quantity from data set
  *
  * @param CmsIndex $cmsIndex
  * @param Cart $cart
  * @param CatalogProductSimple $product
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Cart $cart, CatalogProductSimple $product)
 {
     $productQtyInMiniCart = $cmsIndex->open()->getCartSidebarBlock()->getProductQty($product->getName());
     \PHPUnit_Framework_Assert::assertEquals($productQtyInMiniCart, $cart->getQty(), 'Mini shopping cart product qty: \'' . $productQtyInMiniCart . '\' not equals with qty from data set: \'' . $cart->getQty() . '\'');
 }
 /**
  * Assert that product with Low Stock is present in Low Stock grid
  *
  * @param CatalogProductSimple $product
  * @param ProductLowStock $productLowStock
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, ProductLowStock $productLowStock)
 {
     $productLowStock->open();
     \PHPUnit_Framework_Assert::assertTrue($productLowStock->getLowStockGrid()->isRowVisible(['name' => $product->getName()]), 'Product with Low Stock is absent in Low Stock grid.');
 }
 /**
  * Assert that price in the shopping cart equals to expected price from data set
  *
  * @param CheckoutCart $checkoutCart
  * @param Cart $cart
  * @param CatalogProductSimple $product
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductSimple $product)
 {
     $cartProductPrice = $checkoutCart->open()->getCartBlock()->getProductPriceByName($product->getName());
     \PHPUnit_Framework_Assert::assertEquals($cartProductPrice, $cart->getPrice(), 'Shopping cart product price: \'' . $cartProductPrice . '\' not equals with price from data set: \'' . $cart->getPrice() . '\'');
 }
 /**
  * Get prices with fpt on category, product and cart pages
  *
  * @param CatalogProductSimple $product
  * @return array
  */
 protected function getPrices(CatalogProductSimple $product)
 {
     $actualPrices = [];
     $productName = $product->getName();
     // Get prices with fpt on category page
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
     $actualPrices = $this->getCategoryPrice($productName, $actualPrices);
     // Get prices with fpt on product page
     $this->catalogCategoryView->getListProductBlock()->openProductViewPage($productName);
     $actualPrices = $this->addToCart($product, $actualPrices);
     // Get prices with fpt on cart page
     $actualPrices = $this->getCartPrice($product, $actualPrices);
     return $actualPrices;
 }
 /**
  * Assert that subtotal total in the shopping cart is equals to expected total from data set
  *
  * @param CheckoutCart $checkoutCart
  * @param Cart $cart
  * @param CatalogProductSimple $product
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductSimple $product)
 {
     $cartProductSubtotal = $checkoutCart->open()->getCartBlock()->getCartItemSubTotalByProductName($product->getName());
     \PHPUnit_Framework_Assert::assertEquals($cartProductSubtotal, $cart->getRowTotal(), 'Shopping cart subtotal: \'' . $cartProductSubtotal . '\' not equals with total from data set: \'' . $cart->getRowTotal() . '\'');
 }
 /**
  * Create products
  *
  * @param CatalogProductSimple $product
  * @param int $countProduct
  * @return string
  */
 protected function createProducts(CatalogProductSimple $product, $countProduct)
 {
     for ($i = 0; $i < $countProduct; $i++) {
         $product->persist();
     }
     return $product->getName();
 }