/**
  * Delete all Catalog Events on backend.
  *
  * @return void
  */
 public function run()
 {
     $this->catalogEventIndex->open();
     $this->catalogEventIndex->getEventGrid()->resetFilter();
     while ($this->catalogEventIndex->getEventGrid()->isFirstRowVisible()) {
         $this->catalogEventIndex->getEventGrid()->openFirstRow();
         $this->catalogEventEdit->getPageActions()->deleteAndAcceptAlert();
     }
 }
 /**
  * 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));
 }
 /**
  * Run delete Catalog Event test.
  *
  * @param CatalogProductSimple $product
  * @return void
  */
 public function test(CatalogProductSimple $product)
 {
     //Steps
     $this->catalogEventIndex->open();
     $this->catalogEventIndex->getEventGrid()->searchAndOpen(['category_name' => $product->getCategoryIds()[0]]);
     $this->catalogEventNew->getPageActions()->deleteAndAcceptAlert();
 }
 /**
  * Create Catalog Event Entity from Catalog Event page.
  *
  * @param CatalogEvent $catalogEvent
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function test(CatalogEvent $catalogEvent, FixtureFactory $fixtureFactory)
 {
     //Preconditions:
     /**@var CatalogProductSimple $product */
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category']);
     $product->persist();
     //Steps:
     $this->catalogEventIndex->open();
     $this->catalogEventIndex->getPageActions()->addNew();
     /** @var CatalogCategory $category */
     $category = $product->getDatafieldConfig('category_ids')['source']->getProductCategory();
     $this->catalogEventNew->getTreeCategories()->selectCategory($category->getPath() . '/' . $category->getName());
     $this->catalogEventNew->getEventForm()->fill($catalogEvent);
     $this->catalogEventNew->getPageActions()->save();
     return ['product' => $product];
 }
 /**
  * Assert that expected success message is present on Catalog Event page.
  *
  * @param CatalogEventIndex $catalogEventIndex
  * @return void
  */
 public function processAssert(CatalogEventIndex $catalogEventIndex)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $catalogEventIndex->getMessagesBlock()->getSuccessMessages());
 }