Skip to content

Commit 216b069

Browse files
committed
MC-40389: Restricted user can change category on All StoreView level
- Adding the plugin for authorization check on category edit
1 parent c959471 commit 216b069

File tree

1 file changed

+36
-2
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml

1 file changed

+36
-2
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\App\ProductMetadata;
1414
use Magento\Framework\App\ProductMetadataInterface;
1515
use Magento\Framework\App\Request\Http as HttpRequest;
16+
use Magento\Framework\Exception\NoSuchEntityException;
1617
use Magento\Framework\Message\MessageInterface;
1718
use Magento\Framework\Registry;
1819
use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
@@ -99,7 +100,7 @@ protected function setUp(): void
99100
* @param array $defaultAttributes
100101
* @param array $attributesSaved
101102
* @return void
102-
* @throws \Magento\Framework\Exception\NoSuchEntityException
103+
* @throws NoSuchEntityException
103104
*/
104105
public function testSaveAction(array $inputData, array $defaultAttributes, array $attributesSaved = []): void
105106
{
@@ -145,7 +146,7 @@ public function testSaveAction(array $inputData, array $defaultAttributes, array
145146
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories.php
146147
* @return void
147148
* @throws \Magento\Framework\Exception\CouldNotSaveException
148-
* @throws \Magento\Framework\Exception\NoSuchEntityException
149+
* @throws NoSuchEntityException
149150
*/
150151
public function testDefaultValueForCategoryUrlPath(): void
151152
{
@@ -237,6 +238,39 @@ public static function categoryCreatedFromProductCreationPageDataProvider(): arr
237238
return [[$postData], [$postData + ['return_session_messages_only' => 1]]];
238239
}
239240

241+
/**
242+
* Test save action with different store
243+
*
244+
* @return void
245+
* @throws NoSuchEntityException
246+
* @magentoDbIsolation enabled
247+
*/
248+
public function testSaveActionWithDifferentStore(): void
249+
{
250+
$categoryDetails =
251+
[
252+
'id' => '20',
253+
'entity_id' => '20',
254+
'path' => '1/2',
255+
'url_key' => 'test-category',
256+
'is_anchor' => false,
257+
'use_default' =>
258+
[
259+
'name' => 'test-category',
260+
'is_active' => 1,
261+
'thumbnail' => 1,
262+
'description' => 'Test description for test-category'
263+
]
264+
];
265+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
266+
$this->getRequest()->setPostValue($categoryDetails);
267+
$this->getRequest()->setParam('id', $categoryDetails['id']);
268+
269+
$this->dispatch('backend/catalog/category/save');
270+
$body = $this->getResponse()->getBody();
271+
$this->assertEmpty($body);
272+
}
273+
240274
/**
241275
* Test SuggestCategories finds any categories.
242276
*

0 commit comments

Comments
 (0)