Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCmsBlockNotInGrid.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Cms\Test\Page\Adminhtml\CmsBlockIndex;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 
16 class AssertCmsBlockNotInGrid extends AbstractConstraint
17 {
28  public function processAssert(CmsBlock $cmsBlock, CmsBlockIndex $cmsBlockIndex)
29  {
30  $cmsBlockIndex->open();
31  $data = $cmsBlock->getData();
32  $data['is_active'] = $data['is_active'] == 'Yes' ? 'Enabled' : 'Disabled';
33  if (isset($data['stores'])) {
34  $storeId = is_array($data['stores']) ? reset($data['stores']) : $data['stores'];
35  $parts = explode("/", $storeId);
36  }
37 
38  $filter = [
39  'title' => $data['title'],
40  'identifier' => $data['identifier'],
41  'is_active' => $data['is_active'],
42  'store_id' => end($parts),
43  ];
44 
45  // add creation_time & update_time to filter if there are ones
46  if (isset($data['creation_time'])) {
47  $filter['creation_time_from'] = date("M j, Y", strtotime($cmsBlock->getCreationTime()));
48  }
49  if (isset($data['update_time'])) {
50  $filter['update_time_from'] = date("M j, Y", strtotime($cmsBlock->getUpdateTime()));
51  }
52 
53  \PHPUnit\Framework\Assert::assertFalse(
54  $cmsBlockIndex->getCmsBlockGrid()->isRowVisible($filter, true, false),
55  'CMS Block with '
56  . 'title \'' . $filter['title'] . '\', '
57  . 'identifier \'' . $filter['identifier'] . '\', '
58  . 'store view \'' . $filter['store_id'] . '\', '
59  . 'status \'' . $filter['is_active'] . '\', '
60  . (isset($filter['creation_time_from'])
61  ? ('creation_time \'' . $filter['creation_time_from'] . '\', ')
62  : '')
63  . (isset($filter['update_time_from']) ? ('update_time \'' . $filter['update_time_from'] . '\'') : '')
64  . 'exists in CMS Block grid.'
65  );
66  }
67 
73  public function toString()
74  {
75  return 'CMS Block is not present in grid.';
76  }
77 }
processAssert(CmsBlock $cmsBlock, CmsBlockIndex $cmsBlockIndex)