/** * Assert that catalog event is presented in the "Events" grid. * * @param CatalogEvent $catalogEvent * @param CatalogProductSimple $product * @param CatalogEventIndex $catalogEventIndex * @return void */ public function processAssert(CatalogEvent $catalogEvent, CatalogProductSimple $product, CatalogEventIndex $catalogEventIndex) { $categoryName = $product->getDatafieldConfig('category_ids')['source']->getProductCategory()->getName(); $dateStart = strtotime($catalogEvent->getDateStart()); $dateEnd = strtotime($catalogEvent->getDateEnd()); $this->catalogEvent = $catalogEvent->getData(); if (!empty($this->catalogEvent['sort_order'])) { $sortOrder = $this->catalogEvent['sort_order'] < 0 ? 0 : $this->catalogEvent['sort_order']; } else { $sortOrder = ""; } $filter = ['category_name' => $categoryName, 'start_on' => $this->prepareDate($dateStart), 'end_on' => $this->prepareDate($dateEnd), 'status' => $this->getStatus($dateStart, $dateEnd), 'countdown_ticker' => $this->prepareDisplayStateForFilter(), 'sort_order' => $sortOrder]; $catalogEventIndex->getEventGrid()->search(['category_name' => $filter['category_name']]); \PHPUnit_Framework_Assert::assertTrue($catalogEventIndex->getEventGrid()->isRowVisible($filter, false, false), "Event on Category Name {$categoryName} is absent in Events grid by next filter:\n" . print_r($filter, true)); }
/** * Assert that Event block is visible/invisible on page according to fixture(catalog page/product pages). * * @param CmsIndex $cmsIndex * @param CatalogEvent $catalogEvent * @param CatalogCategoryView $catalogCategoryView * @param CatalogProductSimple $product * @param CatalogProductView $catalogProductView * @return void */ public function processAssert(CmsIndex $cmsIndex, CatalogEvent $catalogEvent, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CatalogProductView $catalogProductView) { $this->catalogCategoryView = $catalogCategoryView; $this->cmsIndex = $cmsIndex; $this->catalogProductView = $catalogProductView; $this->categoryName = $product->getDatafieldConfig('category_ids')['source']->getProductCategory()->getName(); $this->productName = $product->getName(); $catalogEventData = $catalogEvent->getData(); $this->checkEvent($catalogEventData['display_state']); }