/** * 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']); }
/** * Assert that widget catalog event carousel is present on category page and link "Go To Sale" on widget redirects * you to category page. * * @param CmsIndex $cmsIndex * @param CatalogEventWidget $widget * @param CatalogCategoryView $catalogCategoryView * @param Cache $adminCache * @param CatalogEvent $event1 * @param CatalogEvent $event2 * @return void */ public function processAssert(CmsIndex $cmsIndex, CatalogEventWidget $widget, CatalogCategoryView $catalogCategoryView, Cache $adminCache, CatalogEvent $event1, CatalogEvent $event2) { // Flush cache $adminCache->open(); $adminCache->getPageActions()->flushCacheStorage(); $adminCache->getMessagesBlock()->waitSuccessMessage(); $event1->persist(); $event2->persist(); $cmsIndex->open(); $categoryName = $event2->getCategoryId(); $cmsIndex->getTopmenu()->selectCategory($categoryName); $errors = $catalogCategoryView->getWidgetView()->checkWidget($widget, $categoryName); \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors)); $cmsIndex->open(); $cmsIndex->getWidgetView()->clickToWidget($widget, $categoryName); $pageTitle = $cmsIndex->getCmsPageBlock()->getPageTitle(); $expected = strtolower($categoryName); $actual = strtolower($pageTitle); \PHPUnit_Framework_Assert::assertEquals($expected, $actual, "Wrong page title on Category page: expected = '{$expected}', actual = '{$actual}'"); }
/** * Assert that Event block has $eventStatus. * * @param CmsIndex $cmsIndex * @param CatalogCategoryView $catalogCategoryView * @param CatalogEvent $catalogEvent * @param CatalogProductSimple $product * @param CatalogProductView $catalogProductView */ public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogEvent $catalogEvent, CatalogProductSimple $product, CatalogProductView $catalogProductView) { $this->catalogCategoryView = $catalogCategoryView; $this->cmsIndex = $cmsIndex; $this->product = $product; $this->catalogProductView = $catalogProductView; $pageEvent = $catalogEvent->getDisplayState(); if ($pageEvent['category_page'] == "Yes") { $this->checkEventStatusOnCategoryPage(); } if ($pageEvent['product_page'] == "Yes") { $this->checkEventStatusOnProductPage(); } }