Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateWidgetEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 
25 {
26  /* tags */
27  const MVP = 'yes';
28  const TEST_TYPE = 'extended_acceptance_test';
29  const SEVERITY = 'S1';
30  /* end tags */
31 
37  private $caches = [];
38 
46  public function test(Widget $widget, array $caches = [])
47  {
48  // Preconditions
49  $this->caches = $caches;
50  // Steps
51  $this->widgetInstanceIndex->open();
52  $this->widgetInstanceIndex->getPageActionsBlock()->addNew();
53  $this->widgetInstanceNew->getWidgetForm()->fill($widget);
54  $this->widgetInstanceEdit->getPageActionsBlock()->save();
55  $this->adjustCacheSettings();
56  }
57 
63  private function adjustCacheSettings()
64  {
65  $this->cache->flush();
66  foreach ($this->caches as $cacheType => $cacheStatus) {
67  if ($cacheStatus === 'Disabled') {
68  $this->cache->disableCache($cacheType);
69  }
70  }
71  if (in_array('Invalidated', $this->caches)) {
72  $this->cmsIndex->open();
73  }
74  }
75 
81  public function tearDown()
82  {
83  parent::tearDown();
84  if (!empty($this->caches)) {
85  $this->cache->enableCache();
86  }
87  }
88 }