Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteCmsBlockEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Cms\Test\Page\Adminhtml\CmsBlockIndex;
11 use Magento\Cms\Test\Page\Adminhtml\CmsBlockNew;
12 use Magento\Mtf\TestCase\Injectable;
13 use Magento\Mtf\Fixture\FixtureFactory;
15 
30 class DeleteCmsBlockEntityTest extends Injectable
31 {
32  /* tags */
33  const MVP = 'yes';
34  const SEVERITY = 'S1';
35  /* end tags */
36 
42  protected $cmsBlockIndex;
43 
49  protected $cmsBlockNew;
50 
56  private $fixtureFactory;
57 
66  public function __inject(
67  CmsBlockIndex $cmsBlockIndex,
68  CmsBlockNew $cmsBlockNew,
69  FixtureFactory $fixtureFactory
70  ) {
71  $this->cmsBlockIndex = $cmsBlockIndex;
72  $this->cmsBlockNew = $cmsBlockNew;
73  $this->fixtureFactory = $fixtureFactory;
74  }
75 
82  public function test(CmsBlock $cmsBlock)
83  {
84  // Precondition
85  $cmsBlock->persist();
86  $filter = ['identifier' => $cmsBlock->getIdentifier()];
87  $category = $this->createCategory($cmsBlock);
88 
89  // Steps
90  $this->cmsBlockIndex->open();
91  $this->cmsBlockIndex->getCmsBlockGrid()->searchAndOpen($filter);
92  $this->cmsBlockNew->getFormPageActions()->delete();
93  $this->cmsBlockNew->getModalBlock()->acceptAlert();
94 
95  return ['category' => $category];
96  }
97 
104  private function createCategory(CmsBlock $cmsBlock)
105  {
106  $category = $this->fixtureFactory->createByCode(
107  'category',
108  [
109  'dataset' => 'default_subcategory',
110  'data' => [
111  'display_mode' => 'Static block and products',
112  'landing_page' => $cmsBlock->getTitle(),
113  ]
114  ]
115  );
116  $category->persist();
117 
118  return $category;
119  }
120 }
__inject(CmsBlockIndex $cmsBlockIndex, CmsBlockNew $cmsBlockNew, FixtureFactory $fixtureFactory)