Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteWebsitesEntityStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Backend\Test\Page\Adminhtml\EditWebsite;
10 use Magento\Backend\Test\Page\Adminhtml\DeleteWebsite;
11 use Magento\Backend\Test\Page\Adminhtml\StoreIndex;
12 use Magento\Backup\Test\Page\Adminhtml\BackupIndex;
15 use Magento\Mtf\TestStep\TestStepInterface;
16 use Magento\Mtf\Fixture\FixtureFactory;
17 use Magento\Mtf\Fixture\FixtureInterface;
18 use Magento\Mtf\TestStep\TestStepFactory;
19 
23 class DeleteWebsitesEntityStep implements TestStepInterface
24 {
25  /* tags */
26  const MVP = 'yes';
27  const SEVERITY = 'S2';
28  /* end tags */
29 
33  private $backupIndex;
34 
38  private $storeIndex;
39 
43  private $editWebsite;
44 
48  private $deleteWebsite;
49 
53  private $fixtureFactory;
54 
58  private $item;
59 
63  private $createBackup;
64 
68  private $stepFactory;
69 
82  public function __construct(
83  BackupIndex $backupIndex,
84  StoreIndex $storeIndex,
85  EditWebsite $editWebsite,
86  DeleteWebsite $deleteWebsite,
87  FixtureFactory $fixtureFactory,
88  FixtureInterface $item,
89  TestStepFactory $testStepFactory,
90  $createBackup = 'No'
91  ) {
92  $this->storeIndex = $storeIndex;
93  $this->editWebsite = $editWebsite;
94  $this->backupIndex = $backupIndex;
95  $this->deleteWebsite = $deleteWebsite;
96  $this->item = $item;
97  $this->createBackup = $createBackup;
98  $this->fixtureFactory = $fixtureFactory;
99  $this->stepFactory = $testStepFactory;
100  }
101 
107  public function run()
108  {
110  $enableBackupsStep = $this->stepFactory->create(
111  SetupConfigurationStep::class,
112  ['configData' => 'enable_backups_functionality']
113  );
114  $enableBackupsStep->run();
115  $this->backupIndex->open()->getBackupGrid()->massaction([], 'Delete', true, 'Select All');
116  $this->storeIndex->open();
117  $websiteNames = $this->item->getWebsiteIds();
118  if (is_array($websiteNames) && count($websiteNames) > 0) {
119  $websiteName = end($websiteNames);
120  $this->storeIndex->getStoreGrid()->searchAndOpenWebsiteByName($websiteName);
121  $this->editWebsite->getFormPageActions()->delete();
122  $this->deleteWebsite->getDeleteWebsiteForm()->fillForm(['create_backup' => $this->createBackup]);
123  $this->deleteWebsite->getFormPageActions()->delete();
124  }
125  }
126 }
__construct(BackupIndex $backupIndex, StoreIndex $storeIndex, EditWebsite $editWebsite, DeleteWebsite $deleteWebsite, FixtureFactory $fixtureFactory, FixtureInterface $item, TestStepFactory $testStepFactory, $createBackup='No')