Skip to content

Commit 058988b

Browse files
committed
Merge remote-tracking branch 'mpi/MC-19306' into Chaika-PR-2019-08-27
2 parents 94cac99 + c102859 commit 058988b

File tree

4 files changed

+119
-14
lines changed

4 files changed

+119
-14
lines changed

app/code/Magento/Store/Model/Store.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ public function setCurrentCurrencyCode($code)
912912
$defaultCode = ($this->_storeManager->getStore() !== null)
913913
? $this->_storeManager->getStore()->getDefaultCurrency()->getCode()
914914
: $this->_storeManager->getWebsite()->getDefaultStore()->getDefaultCurrency()->getCode();
915-
915+
916916
$this->_httpContext->setValue(Context::CONTEXT_CURRENCY, $code, $defaultCode);
917917
}
918918
return $this;
@@ -1279,7 +1279,20 @@ public function isActive()
12791279
public function beforeDelete()
12801280
{
12811281
$this->_configDataResource->clearScopeData(ScopeInterface::SCOPE_STORES, $this->getId());
1282-
return parent::beforeDelete();
1282+
parent::beforeDelete();
1283+
if ($this->getId() === $this->getGroup()->getDefaultStoreId()) {
1284+
$ids = $this->getGroup()->getStoreIds();
1285+
if (!empty($ids) && count($ids) > 1) {
1286+
unset($ids[$this->getId()]);
1287+
$defaultId = current($ids);
1288+
} else {
1289+
$defaultId = null;
1290+
}
1291+
$this->getGroup()->setDefaultStoreId($defaultId);
1292+
$this->getGroup()->save();
1293+
}
1294+
1295+
return $this;
12831296
}
12841297

12851298
/**
@@ -1300,18 +1313,6 @@ function () use ($store) {
13001313
parent::afterDelete();
13011314
$this->_configCacheType->clean();
13021315

1303-
if ($this->getId() === $this->getGroup()->getDefaultStoreId()) {
1304-
$ids = $this->getGroup()->getStoreIds();
1305-
if (!empty($ids) && count($ids) > 1) {
1306-
unset($ids[$this->getId()]);
1307-
$defaultId = current($ids);
1308-
} else {
1309-
$defaultId = null;
1310-
}
1311-
$this->getGroup()->setDefaultStoreId($defaultId);
1312-
$this->getGroup()->save();
1313-
}
1314-
13151316
return $this;
13161317
}
13171318

app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateNewStoreGroupActionGroup.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,50 @@
7171
<see selector="{{AdminStoresGridSection.nthRow('1')}}" userInput="{{storeGroupName}}" stepKey="seeAssertStoreGroupInGridMessage"/>
7272
</actionGroup>
7373

74+
<actionGroup name="EditStoreGroupActionGroup">
75+
<annotations>
76+
<description>Edit store group.</description>
77+
</annotations>
78+
<arguments>
79+
<argument name="storeGroupName" type="string"/>
80+
</arguments>
81+
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/>
82+
<waitForPageLoad stepKey="waitForAdminSystemStorePageLoad"/>
83+
<click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/>
84+
<waitForPageLoad stepKey="waitForResetResult"/>
85+
<fillField userInput="{{storeGroupName}}" selector="{{AdminStoresGridSection.storeGrpFilterTextField}}" stepKey="fillStoreGroupFilter"/>
86+
<click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/>
87+
<waitForPageLoad stepKey="waitForSearchResult"/>
88+
<click selector="{{AdminStoresGridSection.storeGrpNameInFirstRow}}" stepKey="clicksStoreGroupName"/>
89+
<waitForPageLoad stepKey="waitForStorePageToLoad"/>
90+
</actionGroup>
91+
92+
<actionGroup name="ChangeDefaultStoreViewActionGroup" extends="EditStoreGroupActionGroup">
93+
<annotations>
94+
<description>Change the default store view for provided store group.</description>
95+
</annotations>
96+
<arguments>
97+
<argument name="storeViewName" type="string"/>
98+
</arguments>
99+
<selectOption selector="{{AdminEditStoreGroupSection.defaultStoreView}}" userInput="{{storeViewName}}" stepKey="changeDefaultStoreView" after="waitForStorePageToLoad"/>
100+
<click selector="{{AdminStoreGroupActionsSection.saveButton}}" stepKey="clickSaveStoreGroup"/>
101+
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModal"/>
102+
<see selector="{{AdminConfirmationModalSection.title}}" userInput="Warning message" stepKey="seeWarningAboutTakingALongTimeToComplete"/>
103+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmModal"/>
104+
<waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="seeForSuccessMessage"/>
105+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the store." stepKey="seeSuccessMessage"/>
106+
</actionGroup>
107+
108+
<actionGroup name="AssertDefaultStoreViewActionGroup" extends="EditStoreGroupActionGroup">
109+
<annotations>
110+
<description>Asserts that the provided store view is default in provided store group.</description>
111+
</annotations>
112+
<arguments>
113+
<argument name="storeViewName" type="string"/>
114+
</arguments>
115+
<seeOptionIsSelected selector="{{AdminEditStoreGroupSection.defaultStoreView}}" userInput="{{storeViewName}}" stepKey="assertDefaultStoreView" after="waitForStorePageToLoad"/>
116+
</actionGroup>
117+
74118
<actionGroup name="AssertStoreGroupForm">
75119
<annotations>
76120
<description>Clicks on the 1st Store in the 'Stores' grid. Validates that the provided Details (Website, Store Group Name, Store Group Code and Root Category) are present and correct.</description>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="AdminEditStoreGroupSection">
10+
<element name="defaultStoreView" type="select" selector="#group_default_store_id"/>
11+
</section>
12+
</sections>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<!-- Test XML Example -->
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminDeleteDefaultStoreViewTest">
11+
<annotations>
12+
<stories value="Store creation ('app:config:import' with pre-defined stores) fails during installation"/>
13+
<title value="Delete Default Store View"/>
14+
<description value="Test another store view should be set as default when default store view is deleted"/>
15+
<testCaseId value="MC-19306"/>
16+
<severity value="CRITICAL"/>
17+
<group value="store"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/>
21+
</before>
22+
<after>
23+
<actionGroup ref="logout" stepKey="logout"/>
24+
</after>
25+
<!--Create custom store view-->
26+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createNewStoreView">
27+
<argument name="StoreGroup" value="_defaultStoreGroup"/>
28+
<argument name="customStore" value="storeViewData"/>
29+
</actionGroup>
30+
31+
<!--Change the default store view to the custom store view-->
32+
<actionGroup ref="ChangeDefaultStoreViewActionGroup" stepKey="changeDefaultStoreViewToCustomStoreView">
33+
<argument name="storeGroupName" value="{{_defaultStoreGroup.name}}"/>
34+
<argument name="storeViewName" value="{{storeViewData.name}}"/>
35+
</actionGroup>
36+
37+
<!--Delete custom store view -->
38+
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteCustomStoreView">
39+
<argument name="customStore" value="storeViewData"/>
40+
</actionGroup>
41+
42+
<!--Verify that the default store view is now the default store view-->
43+
<actionGroup ref="AssertDefaultStoreViewActionGroup" stepKey="assertDefaultStoreViewActionGroup">
44+
<argument name="storeGroupName" value="{{_defaultStoreGroup.name}}"/>
45+
<argument name="storeViewName" value="{{_defaultStore.name}}"/>
46+
</actionGroup>
47+
</test>
48+
</tests>

0 commit comments

Comments
 (0)