Skip to content

Commit 1b6320e

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-60746' into troll_bugfix_kanban
2 parents e43d1ba + 60d79aa commit 1b6320e

File tree

4 files changed

+93
-4
lines changed

4 files changed

+93
-4
lines changed

app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
100100
]
101101
);
102102

103+
$isDisabledStatusField = $storeModel->isReadOnly()
104+
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive());
103105
$fieldset->addField(
104106
'store_is_active',
105107
'select',
@@ -109,10 +111,19 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
109111
'value' => $storeModel->isActive(),
110112
'options' => [0 => __('Disabled'), 1 => __('Enabled')],
111113
'required' => true,
112-
'disabled' => $storeModel->isReadOnly()
113-
|| ($storeModel->getId() && $storeModel->isDefault() && $storeModel->isActive())
114+
'disabled' => $isDisabledStatusField
114115
]
115116
);
117+
if ($isDisabledStatusField) {
118+
$fieldset->addField(
119+
'store_is_active_hidden',
120+
'hidden',
121+
[
122+
'name' => 'store[is_active]',
123+
'value' => $storeModel->isActive(),
124+
]
125+
);
126+
}
116127

117128
$fieldset->addField(
118129
'store_sort_order',

dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Backend\Test\Page\Adminhtml\StoreIndex;
1111
use Magento\Store\Test\Fixture\Store;
1212
use Magento\Mtf\TestCase\Injectable;
13+
use Magento\Store\Test\TestStep\RestoreDefaultStoreViewStep;
1314

1415
/**
1516
* Test Creation for UpdateStoreEntity (Store Management)
@@ -50,17 +51,36 @@ class UpdateStoreEntityTest extends Injectable
5051
*/
5152
protected $editStore;
5253

54+
/**
55+
* Restore Default Store View step.
56+
*
57+
* @var RestoreDefaultStoreViewStep
58+
*/
59+
private $restoreDefaultStoreViewStep;
60+
61+
/**
62+
* Initial store fixture.
63+
*
64+
* @var Store
65+
*/
66+
private $storeInitial;
67+
5368
/**
5469
* Preparing pages for test
5570
*
5671
* @param StoreIndex $storeIndex
5772
* @param EditStore $editStore
73+
* @param RestoreDefaultStoreViewStep $restoreDefaultStoreViewStep
5874
* @return void
5975
*/
60-
public function __inject(StoreIndex $storeIndex, EditStore $editStore)
61-
{
76+
public function __inject(
77+
StoreIndex $storeIndex,
78+
EditStore $editStore,
79+
RestoreDefaultStoreViewStep $restoreDefaultStoreViewStep
80+
) {
6281
$this->storeIndex = $storeIndex;
6382
$this->editStore = $editStore;
83+
$this->restoreDefaultStoreViewStep = $restoreDefaultStoreViewStep;
6484
}
6585

6686
/**
@@ -73,6 +93,7 @@ public function __inject(StoreIndex $storeIndex, EditStore $editStore)
7393
public function test(Store $storeInitial, Store $store)
7494
{
7595
// Preconditions:
96+
$this->storeInitial = $storeInitial;
7697
$storeInitial->persist();
7798

7899
// Steps:
@@ -81,4 +102,14 @@ public function test(Store $storeInitial, Store $store)
81102
$this->editStore->getStoreForm()->fill($store);
82103
$this->editStore->getFormPageActions()->save();
83104
}
105+
106+
/**
107+
* {@inheritdoc}
108+
*/
109+
protected function tearDown()
110+
{
111+
if ($this->storeInitial->getCode() == 'default') {
112+
$this->restoreDefaultStoreViewStep->run();
113+
}
114+
}
84115
}

dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@
2020
<constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" />
2121
<constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" />
2222
</variation>
23+
<variation name="UpdateStoreEntityTestVariation2">
24+
<data name="tag" xsi:type="string">severity:S1</data>
25+
<data name="storeInitial/dataset" xsi:type="string">default</data>
26+
<data name="store/data/name" xsi:type="string">storename_updated%isolation%</data>
27+
<constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" />
28+
</variation>
2329
</testCase>
2430
</config>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Store\Test\TestStep;
8+
9+
use Magento\Mtf\TestStep\TestStepInterface;
10+
use Magento\Store\Test\Fixture\Store;
11+
12+
/**
13+
* Restore DefaultStore view.
14+
*/
15+
class RestoreDefaultStoreViewStep implements TestStepInterface
16+
{
17+
/**
18+
* Fixture of Store View.
19+
*
20+
* @var Store
21+
*/
22+
private $storeView;
23+
24+
/**
25+
* @param Store $storeView
26+
*/
27+
public function __construct(Store $storeView)
28+
{
29+
$this->storeView = $storeView;
30+
}
31+
32+
/**
33+
* Restore Default Store View.
34+
*
35+
* @return void
36+
*/
37+
public function run()
38+
{
39+
$this->storeView->persist();
40+
}
41+
}

0 commit comments

Comments
 (0)