/**
  * Assert that created CMS block displayed on frontend category page (in order to assign block to category:
  * go to category page> Display settings> CMS Block).
  *
  * @param CmsIndex $cmsIndex
  * @param CmsBlock $cmsBlock
  * @param CatalogCategoryView $catalogCategoryView
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CmsBlock $cmsBlock, CatalogCategoryView $catalogCategoryView, FixtureFactory $fixtureFactory)
 {
     $category = $fixtureFactory->createByCode('category', ['dataset' => 'default_subcategory', 'data' => ['display_mode' => 'Static block and products', 'landing_page' => $cmsBlock->getTitle()]]);
     $category->persist();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $categoryViewContent = $catalogCategoryView->getViewBlock()->getContent();
     \PHPUnit_Framework_Assert::assertEquals($cmsBlock->getContent(), $categoryViewContent, 'Wrong block content on category is displayed.');
 }
 /**
  * Create CMS Block.
  *
  * @param CmsBlock $cmsBlock
  * @return void
  */
 public function test(CmsBlock $cmsBlock)
 {
     // Prepare data for tearDown
     $this->storeName = $cmsBlock->getStores();
     // Steps
     $this->cmsBlockIndex->open();
     $this->cmsBlockIndex->getGridPageActions()->addNew();
     $this->cmsBlockNew->getCmsForm()->fill($cmsBlock);
     $this->cmsBlockNew->getFormPageActions()->save();
 }
 /**
  * Delete CMS Block.
  *
  * @param CmsBlock $cmsBlock
  * @return void
  */
 public function test(CmsBlock $cmsBlock)
 {
     // Precondition
     $cmsBlock->persist();
     $filter = ['identifier' => $cmsBlock->getIdentifier()];
     // Steps
     $this->cmsBlockIndex->open();
     $this->cmsBlockIndex->getCmsBlockGrid()->searchAndOpen($filter, true, false);
     $this->cmsBlockNew->getFormPageActions()->delete();
 }
 /**
  * Run Update CMS Block test.
  *
  * @param CmsBlock $initialCmsBlock
  * @param CmsBlock $cmsBlock
  * @return void
  */
 public function test(CmsBlock $initialCmsBlock, CmsBlock $cmsBlock)
 {
     // Prepare data for tearDown
     $this->storeName = $cmsBlock->getStores();
     // Precondition
     $initialCmsBlock->persist();
     // Steps
     $this->cmsBlockIndex->open();
     $this->cmsBlockIndex->getCmsBlockGrid()->searchAndOpen(['identifier' => $initialCmsBlock->getIdentifier()]);
     $this->cmsBlockNew->getCmsForm()->fill($cmsBlock);
     $this->cmsBlockNew->getFormPageActions()->save();
 }
 /**
  * Assert that created CMS block can't be found in grid via:
  * title, identifier, store view, status, created and modified date
  *
  * @param CmsBlock $cmsBlock
  * @param CmsBlockIndex $cmsBlockIndex
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(CmsBlock $cmsBlock, CmsBlockIndex $cmsBlockIndex)
 {
     $cmsBlockIndex->open();
     $data = $cmsBlock->getData();
     if (isset($data['stores'])) {
         $storeId = is_array($data['stores']) ? reset($data['stores']) : $data['stores'];
         $parts = explode("/", $storeId);
     }
     $filter = ['title' => $data['title'], 'identifier' => $data['identifier'], 'is_active' => $data['is_active'], 'store_id' => end($parts)];
     // add creation_time & update_time to filter if there are ones
     if (isset($data['creation_time'])) {
         $filter['creation_time_from'] = date("M j, Y", strtotime($cmsBlock->getCreationTime()));
     }
     if (isset($data['update_time'])) {
         $filter['update_time_from'] = date("M j, Y", strtotime($cmsBlock->getUpdateTime()));
     }
     \PHPUnit_Framework_Assert::assertFalse($cmsBlockIndex->getCmsBlockGrid()->isRowVisible($filter, true, false), 'CMS Block with ' . 'title \'' . $filter['title'] . '\', ' . 'identifier \'' . $filter['identifier'] . '\', ' . 'store view \'' . $filter['store_id'] . '\', ' . 'status \'' . $filter['is_active'] . '\', ' . (isset($filter['creation_time_from']) ? 'creation_time \'' . $filter['creation_time_from'] . '\', ' : '') . (isset($filter['update_time_from']) ? 'update_time \'' . $filter['update_time_from'] . '\'' : '') . 'exists in CMS Block grid.');
 }
 /**
  * Assert that created CMS block can be found in grid via:
  * title, identifier, store view, status, created and modified date.
  *
  * @param CmsBlock $cmsBlock
  * @param CmsBlockIndex $cmsBlockIndex
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(CmsBlock $cmsBlock, CmsBlockIndex $cmsBlockIndex)
 {
     $cmsBlockIndex->open();
     $data = $cmsBlock->getData();
     $data['is_active'] = $data['is_active'] == 'Yes' ? 'Enabled' : 'Disabled';
     $filter = ['title' => $data['title'], 'identifier' => $data['identifier'], 'is_active' => $data['is_active']];
     if (isset($data['stores'])) {
         $filter['store_id'] = is_array($data['stores']) ? reset($data['stores']) : $data['stores'];
     }
     // add creation_time & update_time to filter if there are ones
     if (isset($data['creation_time'])) {
         $filter['creation_time_from'] = date("M j, Y", strtotime($cmsBlock->getCreationTime()));
     }
     if (isset($data['update_time'])) {
         $filter['update_time_from'] = date("M j, Y", strtotime($cmsBlock->getUpdateTime()));
     }
     $cmsBlockIndex->getCmsBlockGrid()->search($filter);
     if (isset($filter['store_id'])) {
         $pieces = explode('/', $filter['store_id']);
         $filter['store_id'] = end($pieces);
     }
     \PHPUnit_Framework_Assert::assertTrue($cmsBlockIndex->getCmsBlockGrid()->isRowVisible($filter, false, false), 'CMS Block with ' . 'title \'' . $filter['title'] . '\', ' . 'identifier \'' . $filter['identifier'] . '\', ' . 'store view \'' . $filter['store_id'] . '\', ' . 'status \'' . $filter['is_active'] . '\', ' . (isset($filter['creation_time_from']) ? 'creation_time \'' . $filter['creation_time_from'] . '\', ' : '') . (isset($filter['update_time_from']) ? 'update_time \'' . $filter['update_time_from'] . '\'' : '') . 'is absent in CMS Block grid.');
 }