Skip to content

Commit 75414ba

Browse files
committed
MAGETWO-54026: Automated move store to another group within a website.
1 parent 7800e37 commit 75414ba

File tree

5 files changed

+161
-0
lines changed

5 files changed

+161
-0
lines changed

dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class StoreForm extends Form
2222
*/
2323
protected $store = '//option[contains(.,"%s")]';
2424

25+
/**
26+
* Store dropdown selector
27+
*
28+
* @var string
29+
*/
30+
protected $storeGroupId = '//select[@id="store_group_id"]';
31+
2532
/**
2633
* Check that Store visible in Store dropdown
2734
*
@@ -32,4 +39,15 @@ public function isStoreVisible($name)
3239
{
3340
return $this->_rootElement->find(sprintf($this->store, $name), Locator::SELECTOR_XPATH)->isVisible();
3441
}
42+
43+
/**
44+
* Select store view by name from dropdown
45+
*
46+
* @param string $name
47+
* @return bool
48+
*/
49+
public function selectStore($name)
50+
{
51+
return $this->_rootElement->find($this->storeGroupId, Locator::SELECTOR_XPATH, 'optgroupselect')->setValue($name);
52+
}
3553
}

dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, array
4040
$this->storeGroup = $storeGroup;
4141
$this->data = $storeGroup->getWebsiteId() . "/" . $storeGroup->getName();
4242
}
43+
44+
if (isset($data['storeGroup']) && $data['storeGroup'] instanceof StoreGroup) {
45+
$this->storeGroup = $data['storeGroup'];
46+
$this->data = $data['storeGroup']->getWebsiteId() . "/" . $data['storeGroup']->getName();
47+
}
48+
49+
if (isset($data['value'])) {
50+
$this->data = $data['value'];
51+
}
4352
}
4453

4554
/**

dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,14 @@
5252
<field name="code" xsi:type="string">store_%isolation%</field>
5353
<field name="is_active" xsi:type="string">Enabled</field>
5454
</dataset>
55+
56+
<dataset name="custom_group_custom_store">
57+
<field name="group_id" xsi:type="array">
58+
<item name="dataset" xsi:type="string">custom</item>
59+
</field>
60+
<field name="name" xsi:type="string">Custom_Store_%isolation%</field>
61+
<field name="code" xsi:type="string">code_%isolation%</field>
62+
<field name="is_active" xsi:type="string">Enabled</field>
63+
</dataset>
5564
</repository>
5665
</config>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Store\Test\TestCase;
8+
9+
use Magento\Backend\Test\Page\Adminhtml\EditStore;
10+
use Magento\Backend\Test\Page\Adminhtml\StoreIndex;
11+
use Magento\Store\Test\Fixture\Store;
12+
use Magento\Mtf\TestCase\Injectable;
13+
use Magento\Mtf\Fixture\FixtureFactory;
14+
15+
/**
16+
* Test Move Store view to another store within same website (Store Management)
17+
*
18+
* Test Flow:
19+
*
20+
* Preconditions:
21+
* 1.Create store STA with store view SVA
22+
* 2.Create store STB with store view SVB
23+
* 3.STA and STB belong to the same website
24+
*
25+
* Steps:
26+
* 1. Open Backend
27+
* 2. Go to Stores -> All Stores
28+
* 3. Open store view SVB from grid
29+
* 4. Change store group setting from STB to STA
30+
* 5. Save store entity
31+
* 6. Perform all assertions
32+
*
33+
* @group Store_Management
34+
* @ZephyrId MAGETWO-54026
35+
*/
36+
class MoveStoreToOtherGroupSameWebsiteTest extends Injectable
37+
{
38+
/* tags */
39+
const MVP = 'yes';
40+
const SEVERITY = 'S1';
41+
/* end tags */
42+
43+
/**
44+
* Page StoreIndex
45+
*
46+
* @var StoreIndex
47+
*/
48+
protected $storeIndex;
49+
50+
/**
51+
* Page EditStore
52+
*
53+
* @var EditStore
54+
*/
55+
protected $editStore;
56+
57+
/**
58+
* Preparing pages for test
59+
*
60+
* @param StoreIndex $storeIndex
61+
* @param EditStore $editStore
62+
* @return void
63+
*/
64+
public function __inject(StoreIndex $storeIndex, EditStore $editStore)
65+
{
66+
$this->storeIndex = $storeIndex;
67+
$this->editStore = $editStore;
68+
}
69+
70+
/**
71+
* Move store view to another store group within a website
72+
*
73+
* @param FixtureFactory $fixtureFactory
74+
* @param Store $storeInitialA
75+
* @param Store $storeInitialB
76+
* @return array
77+
*/
78+
public function test(FixtureFactory $fixtureFactory, Store $storeInitialA, Store $storeInitialB)
79+
{
80+
// Prepare data for constraints
81+
$store = $fixtureFactory->createByCode(
82+
'store',
83+
[
84+
'data' => [
85+
'name' => $storeInitialB->getName(),
86+
'code' => $storeInitialB->getCode(),
87+
'is_active' => $storeInitialB->getIsActive(),
88+
'group_id' => ['storeGroup' => $storeInitialA->getDataFieldConfig('group_id')['source']->getStoreGroup()],
89+
]
90+
]
91+
);
92+
93+
// Preconditions
94+
$storeInitialA->persist();
95+
$storeInitialB->persist();
96+
97+
// Steps
98+
$this->storeIndex->open();
99+
$this->storeIndex->getStoreGrid()->searchAndOpenStore($storeInitialB);
100+
$this->editStore->getStoreForm()->selectStore($storeInitialA->getGroupId());
101+
$this->editStore->getFormPageActions()->save();
102+
103+
return ['store' => $store];
104+
}
105+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Store\Test\TestCase\MoveStoreToOtherGroupSameWebsiteTest" summary="Move Store View" ticketId="MAGETWO-54026">
10+
<variation name="MoveStoreTestVariation1">
11+
<data name="storeInitialA/dataset" xsi:type="string">custom_group_custom_store</data>
12+
<data name="storeInitialB/dataset" xsi:type="string">custom_group_custom_store</data>
13+
<constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" />
14+
<constraint name="Magento\Store\Test\Constraint\AssertStoreInGrid" />
15+
<constraint name="Magento\Store\Test\Constraint\AssertStoreForm" />
16+
<constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" />
17+
<constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" />
18+
</variation>
19+
</testCase>
20+
</config>

0 commit comments

Comments
 (0)