/** * Assert that product is not displayed in cross-sell section * * @param BrowserInterface $browser * @param CatalogProductSimple $product * @param InjectableFixture[] $relatedProducts * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @return void */ public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, array $relatedProducts, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart) { $checkoutCart->open(); $checkoutCart->getCartBlock()->clearShoppingCart(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); foreach ($relatedProducts as $relatedProduct) { \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->verifyProductCrosssell($relatedProduct), 'Product \'' . $relatedProduct->getName() . '\' is exist in cross-sell section.'); } }
/** * 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.'); }
/** * Assert that product is displayed in cross-sell section * * @param BrowserInterface $browser * @param CheckoutCart $checkoutCart * @param CatalogProductSimple $product * @param CatalogProductView $catalogProductView * @param InjectableFixture[] $relatedProducts * @return void */ public function processAssert(BrowserInterface $browser, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $relatedProducts) { $checkoutCart->open(); $checkoutCart->getCartBlock()->clearShoppingCart(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); $errors = []; foreach ($relatedProducts as $relatedProduct) { if (!$checkoutCart->getCrosssellBlock()->verifyProductCrosssell($relatedProduct)) { $errors[] = 'Product \'' . $relatedProduct->getName() . '\' is absent in cross-sell section.'; } } \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors)); }
/** * Assert that product is not displayed in cross-sell section. * * @param BrowserInterface $browser * @param CatalogProductSimple $product * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param InjectableFixture[]|null $promotedProducts * @return void */ public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, array $promotedProducts = null) { if (!$promotedProducts) { $promotedProducts = $product->hasData('cross_sell_products') ? $product->getDataFieldConfig('cross_sell_products')['source']->getProducts() : []; } $checkoutCart->open(); $checkoutCart->getCartBlock()->clearShoppingCart(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); foreach ($promotedProducts as $promotedProduct) { \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.'); } }
/** * Assert that cross-sell products section is displayed correctly. * * @param array $promotedProductNames * @return void */ protected function assertCrossSellSection(array $promotedProductNames) { $productNames = []; $pageProductNames = []; foreach ($promotedProductNames as $promotedProductName) { $productNames[] = $this->products[$promotedProductName]->getName(); } $this->checkoutCart->open(); foreach ($this->checkoutCart->getCrosssellBlock()->getProducts() as $productItem) { $pageProductNames[] = $productItem->getProductName(); } sort($productNames); sort($pageProductNames); \PHPUnit_Framework_Assert::assertEquals($productNames, $pageProductNames, 'Wrong products are displayed in cross-sell section.'); }