Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertWidgetCatalogNewProductsList.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\PageCache\Test\Page\Adminhtml\AdminCache;
10 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11 use Magento\Cms\Test\Page\CmsIndex;
13 use Magento\Mtf\Constraint\AbstractConstraint;
15 
19 class AssertWidgetCatalogNewProductsList extends AbstractConstraint
20 {
27 
39  public function processAssert(
40  CmsIndex $cmsIndex,
41  CatalogCategoryView $catalogCategoryView,
42  CatalogProductSimple $productSimple1,
43  CatalogProductSimple $productSimple2,
44  Widget $widget,
45  AdminCache $adminCache
46  ) {
47  $this->catalogCategoryView = $catalogCategoryView;
48 
49  // Flush cache
50  $adminCache->open();
51  $adminCache->getActionsBlock()->flushMagentoCache();
52  $adminCache->getMessagesBlock()->waitSuccessMessage();
53 
54  $productSimple1->persist();
55  $productSimple2->persist();
56  $products[] = $productSimple2->getName();
57  $products[] = $productSimple1->getName();
58 
59  $cmsIndex->open();
60  $categoryName = $widget->getWidgetInstance()[0]['entities']->getName();
61  $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
62  \PHPUnit\Framework\Assert::assertTrue(
63  $catalogCategoryView->getWidgetView()->isWidgetVisible($widget, 'New Products'),
64  'Widget is absent on Category page.'
65  );
66  \PHPUnit\Framework\Assert::assertEquals(
67  $products,
68  $this->catalogCategoryView->getViewBlock()->getProductsFromCatalogNewProductsListBlock(),
69  'There are wrong products or products are absent on Catalog New Products List block on Category page.'
70  );
71  }
72 
78  public function toString()
79  {
80  return "Catalog New Products List widget is present on Category page.";
81  }
82 }
processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $productSimple1, CatalogProductSimple $productSimple2, Widget $widget, AdminCache $adminCache)