Skip to content

Commit 139f567

Browse files
Merge remote-tracking branch 'origin/MAGETWO-51882-update-custom-variable' into develop
2 parents c6ff212 + d16baf2 commit 139f567

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

dev/tests/functional/tests/app/Magento/Variable/Test/Constraint/AssertCustomVariableForm.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function processAssert(
4848
? $customVariable->getData()
4949
: array_merge($customVariableOrigin->getData(), $customVariable->getData());
5050
if ($customVariableOrigin !== null) {
51-
$dataOrigin = $data;
51+
$dataOrigin = $this->arrayCopy($data);
5252
$dataOrigin['html_value'] = $customVariableOrigin->getHtmlValue();
5353
$dataOrigin['plain_value'] = $customVariableOrigin->getPlainValue();
5454
} else {
55-
$dataOrigin = $data;
55+
$dataOrigin = $this->arrayCopy($data);
5656
}
5757
if ($data['html_value'] == '') {
5858
$data['html_value'] = $customVariableOrigin->getHtmlValue();
@@ -86,4 +86,20 @@ public function toString()
8686
{
8787
return 'Displayed Custom Variable data on edit page(backend) equals to passed from fixture.';
8888
}
89+
90+
/**
91+
* Return a copy of the source array.
92+
* To workaround an issue that an array assignment is handled by reference in PHP 7.0.5 in certain situation.
93+
*
94+
* @param array $sourceArray
95+
* @return array
96+
*/
97+
private function arrayCopy($sourceArray)
98+
{
99+
$copyArray = [];
100+
foreach ($sourceArray as $key => $value) {
101+
$copyArray[$key] = $value;
102+
}
103+
return $copyArray;
104+
}
89105
}

dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/UpdateCustomVariableEntityTest.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,55 +65,46 @@ class UpdateCustomVariableEntityTest extends Injectable
6565
*
6666
* @param SystemVariableIndex $systemVariableIndex
6767
* @param SystemVariableNew $systemVariableNew
68-
* @param SystemVariable $customVariableOrigin
69-
* @param FixtureFactory $factory
70-
* @return array
68+
* @return void
7169
*/
7270
public function __inject(
7371
SystemVariableIndex $systemVariableIndex,
74-
SystemVariableNew $systemVariableNew,
75-
SystemVariable $customVariableOrigin,
76-
FixtureFactory $factory
72+
SystemVariableNew $systemVariableNew
7773
) {
7874
$this->systemVariableIndexPage = $systemVariableIndex;
7975
$this->systemVariableNewPage = $systemVariableNew;
80-
81-
$customVariableOrigin->persist();
82-
83-
// TODO: Move store creation to "__prepare" method after fix bug MAGETWO-29331
84-
$storeOrigin = $factory->createByCode('store', ['dataset' => 'custom']);
85-
$storeOrigin->persist();
86-
$this->store = $storeOrigin;
87-
88-
return [
89-
'customVariableOrigin' => $customVariableOrigin,
90-
'storeOrigin' => $storeOrigin
91-
];
9276
}
9377

9478
/**
9579
* Update Custom System Variable Entity test.
9680
*
81+
* @param FixtureFactory $fixtureFactory
9782
* @param SystemVariable $customVariable
9883
* @param SystemVariable $customVariableOrigin
99-
* @param Store $storeOrigin
10084
* @param string $saveAction
101-
* @return void
85+
* @return array
10286
*/
10387
public function test(
88+
FixtureFactory $fixtureFactory,
10489
SystemVariable $customVariable,
10590
SystemVariable $customVariableOrigin,
106-
Store $storeOrigin,
10791
$saveAction
10892
) {
93+
$this->store = $fixtureFactory->createByCode('store', ['dataset' => 'custom']);
94+
$this->store->persist();
95+
$customVariableOrigin->persist();
10996
$filter = ['code' => $customVariableOrigin->getCode()];
11097

11198
// Steps
11299
$this->systemVariableIndexPage->open();
113100
$this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter);
114-
$this->systemVariableNewPage->getFormPageActions()->selectStoreView($storeOrigin->getData('name'));
101+
$this->systemVariableNewPage->getFormPageActions()->selectStoreView($this->store->getData('name'));
115102
$this->systemVariableNewPage->getSystemVariableForm()->fill($customVariable);
116103
$this->systemVariableNewPage->getFormPageActions()->$saveAction();
104+
return [
105+
'storeOrigin' => $this->store,
106+
'customVariableOrigin' => $customVariableOrigin
107+
];
117108
}
118109

119110
/**
@@ -123,7 +114,6 @@ public function test(
123114
*/
124115
public function tearDown()
125116
{
126-
// TODO: Move store clean up to "tearDownAfterClass" method after fix bug MAGETWO-29331
127117
if ($this->store !== null) {
128118
$storeIndex = $this->objectManager->create('Magento\Backend\Test\Page\Adminhtml\StoreIndex');
129119
$storeIndex->open();

dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/UpdateCustomVariableEntityTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<data name="saveAction" xsi:type="string">save</data>
5151
<constraint name="Magento\Variable\Test\Constraint\AssertCustomVariableSuccessSaveMessage" />
5252
<constraint name="Magento\Variable\Test\Constraint\AssertCustomVariableInGrid" />
53+
<constraint name="Magento\Variable\Test\Constraint\AssertCustomVariableForm" />
5354
<constraint name="Magento\Variable\Test\Constraint\AssertCustomVariableInPage" />
5455
</variation>
5556
</testCase>

0 commit comments

Comments
 (0)