Skip to content

Commit ace514e

Browse files
committed
MAGETWO-86480: Restricted admin user can remove product from other websites
1 parent d91c0c0 commit ace514e

File tree

25 files changed

+353
-124
lines changed

25 files changed

+353
-124
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="ProductInWebsitesSection">
12+
<element name="sectionHeader" type="button" selector="div[data-index='websites']"/>
13+
<element name="website" type="checkbox" selector="//label[contains(text(), '{{var1}}')]/parent::div//input[@type='checkbox']" parameterized="true"/>
14+
<element name="isWebsiteDisabled" type="checkbox" selector="//label[contains(text(), '{{websiteName}}')]/parent::div//input[@type='checkbox' and @disabled]" parameterized="true"/>
15+
</section>
16+
</sections>

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ protected function setUp()
6363
'getAttributes',
6464
'getStore',
6565
'getAttributeDefaultValue',
66-
'getExistsStoreValueFlag'
66+
'getExistsStoreValueFlag',
67+
'isLockedAttribute'
6768
])->getMockForAbstractClass();
6869
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
6970
->setMethods(['load', 'getId', 'getConfig'])
@@ -81,9 +82,6 @@ protected function setUp()
8182
$this->arrayManagerMock->expects($this->any())
8283
->method('set')
8384
->willReturnArgument(1);
84-
$this->arrayManagerMock->expects($this->any())
85-
->method('merge')
86-
->willReturnArgument(1);
8785
$this->arrayManagerMock->expects($this->any())
8886
->method('remove')
8987
->willReturnArgument(1);

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributeSetTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
77

8+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
89
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AttributeSet;
910
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory;
1011
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection;
@@ -84,7 +85,31 @@ protected function createModel()
8485

8586
public function testModifyMeta()
8687
{
87-
$this->assertNotEmpty($this->getModel()->modifyMeta(['test_group' => []]));
88+
$modifyMeta = $this->getModel()->modifyMeta(['test_group' => []]);
89+
$this->assertNotEmpty($modifyMeta);
90+
}
91+
92+
/**
93+
* @param bool $locked
94+
* @return void
95+
* @dataProvider modifyMetaLockedDataProvider
96+
*/
97+
public function testModifyMetaLocked($locked)
98+
{
99+
$this->productMock->expects($this->any())
100+
->method('isLockedAttribute')
101+
->willReturn($locked);
102+
$modifyMeta = $this->getModel()->modifyMeta([AbstractModifier::DEFAULT_GENERAL_PANEL => []]);
103+
$children = $modifyMeta[AbstractModifier::DEFAULT_GENERAL_PANEL]['children'];
104+
$this->assertEquals(
105+
$locked,
106+
$children['attribute_set_id']['arguments']['data']['config']['disabled']
107+
);
108+
}
109+
110+
public function modifyMetaLockedDataProvider()
111+
{
112+
return [[true], [false]];
88113
}
89114

90115
public function testModifyMetaToBeEmpty()

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,45 @@ public function testModifyMeta()
114114
$this->assertArrayHasKey($groupCode, $this->getModel()->modifyMeta($meta));
115115
}
116116

117+
/**
118+
* @param bool $locked
119+
* @return void
120+
* @dataProvider modifyMetaLockedDataProvider
121+
*/
122+
public function testModifyMetaLocked($locked)
123+
{
124+
$groupCode = 'test_group_code';
125+
$meta = [
126+
$groupCode => [
127+
'children' => [
128+
'category_ids' => [
129+
'sortOrder' => 10,
130+
],
131+
],
132+
],
133+
];
134+
135+
$this->arrayManagerMock->expects($this->any())
136+
->method('findPath')
137+
->willReturn('path');
138+
139+
$this->productMock->expects($this->any())
140+
->method('isLockedAttribute')
141+
->willReturn($locked);
142+
143+
$this->arrayManagerMock->expects($this->any())
144+
->method('merge')
145+
->willReturnArgument(2);
146+
147+
$modifyMeta = $this->createModel()->modifyMeta($meta);
148+
$this->assertEquals($locked, $modifyMeta['arguments']['data']['config']['disabled']);
149+
}
150+
151+
public function modifyMetaLockedDataProvider()
152+
{
153+
return [[true], [false]];
154+
}
155+
117156
public function testModifyMetaWithCaching()
118157
{
119158
$this->arrayManagerMock->expects($this->exactly(2))

0 commit comments

Comments
 (0)