Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateCustomVariableEntityTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Variable\Test\Fixture\SystemVariable;
10 use Magento\Variable\Test\Page\Adminhtml\SystemVariableIndex;
11 use Magento\Variable\Test\Page\Adminhtml\SystemVariableNew;
13 use Magento\Mtf\Fixture\FixtureFactory;
14 use Magento\Mtf\TestCase\Injectable;
15 use Magento\Mtf\TestStep\TestStepFactory;
16 
36 class UpdateCustomVariableEntityTest extends Injectable
37 {
38  /* tags */
39  const MVP = 'yes';
40  /* end tags */
41 
48 
55 
61  protected $store = null;
62 
68  private $configData;
69 
75  private $testStepFactory;
76 
85  public function __inject(
86  SystemVariableIndex $systemVariableIndex,
87  SystemVariableNew $systemVariableNew,
88  TestStepFactory $testStepFactory
89  ) {
90  $this->systemVariableIndexPage = $systemVariableIndex;
91  $this->systemVariableNewPage = $systemVariableNew;
92  $this->testStepFactory = $testStepFactory;
93  }
94 
105  public function test(
106  FixtureFactory $fixtureFactory,
107  SystemVariable $customVariable,
108  SystemVariable $customVariableOrigin,
109  $saveAction,
110  $configData = null
111  ) {
112  // Preconditions
113  $this->configData = $configData;
114  $this->testStepFactory->create(
115  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
116  ['configData' => $this->configData]
117  )->run();
118  $this->store = $fixtureFactory->createByCode('store', ['dataset' => 'custom']);
119  $this->store->persist();
120  $customVariableOrigin->persist();
121  $filter = ['code' => $customVariableOrigin->getCode()];
122 
123  // Steps
124  $this->systemVariableIndexPage->open();
125  $this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter);
126  $this->systemVariableNewPage->getFormPageActions()->selectStoreView($this->store->getData('name'));
127  $this->systemVariableNewPage->getSystemVariableForm()->fill($customVariable);
128  $this->systemVariableNewPage->getFormPageActions()->$saveAction();
129  return [
130  'storeOrigin' => $this->store,
131  'customVariableOrigin' => $customVariableOrigin
132  ];
133  }
134 
140  public function tearDown()
141  {
142  if ($this->store !== null) {
143  $storeIndex = $this->objectManager->create(\Magento\Backend\Test\Page\Adminhtml\StoreIndex::class);
144  $storeIndex->open();
145  $storeIndex->getStoreGrid()->searchAndOpen(['store_title' => $this->store->getName()]);
146  $storeNew = $this->objectManager->create(\Magento\Backend\Test\Page\Adminhtml\StoreNew::class);
147  $storeNew->getFormPageActions()->delete();
148  $storeDelete = $this->objectManager->create(\Magento\Backend\Test\Page\Adminhtml\StoreDelete::class);
149  $storeDelete->getStoreForm()->fillForm(['create_backup' => 'No']);
150  $storeDelete->getFormPageActions()->delete();
151  }
152  $this->store = null;
153  }
154 }
__inject(SystemVariableIndex $systemVariableIndex, SystemVariableNew $systemVariableNew, TestStepFactory $testStepFactory)
test(FixtureFactory $fixtureFactory, SystemVariable $customVariable, SystemVariable $customVariableOrigin, $saveAction, $configData=null)