Skip to content

Commit 94d9f89

Browse files
committed
Merge branch 'MC-40068' into 2.4-develop-sidecar-pr9
2 parents e64180c + 048ada3 commit 94d9f89

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,51 @@ public function testDeleteNoSuchEntityException()
184184

185185
/**
186186
* @dataProvider deleteSystemOrRootDataProvider
187+
*
188+
* @param int $categoryId
189+
* @param string $exceptionMsg
190+
* @return void
187191
*/
188-
public function testDeleteSystemOrRoot()
192+
public function testDeleteSystemOrRoot(int $categoryId, string $exceptionMsg): void
189193
{
190194
$this->expectException(\Exception::class);
195+
$this->expectExceptionMessage($exceptionMsg);
191196

192-
$this->deleteCategory($this->modelId);
197+
$this->deleteCategory($categoryId);
193198
}
194199

195-
public function deleteSystemOrRootDataProvider()
200+
/**
201+
* @return array
202+
*/
203+
public function deleteSystemOrRootDataProvider(): array
196204
{
197205
return [
198-
[Category::TREE_ROOT_ID],
199-
[2] //Default root category
206+
'system_category' => [
207+
'category_id' => Category::TREE_ROOT_ID,
208+
'exception_message' => $this->buildExceptionMessage(Category::TREE_ROOT_ID),
209+
],
210+
'root_category' => [
211+
'category_id' => 2,
212+
'exception_message' => $this->buildExceptionMessage(2),
213+
],
200214
];
201215
}
202216

217+
/**
218+
* Build response error message
219+
*
220+
* @param int $categoryId
221+
* @return string
222+
*/
223+
private function buildExceptionMessage(int $categoryId): string
224+
{
225+
$translatedMsg = (string)__('Cannot delete category with id %1');
226+
227+
return TESTS_WEB_API_ADAPTER === self::ADAPTER_REST
228+
? sprintf('{"message":"%s","parameters":["%u"]}', $translatedMsg, $categoryId)
229+
: $translatedMsg;
230+
}
231+
203232
/**
204233
* @magentoApiDataFixture Magento/Catalog/_files/category.php
205234
*/

0 commit comments

Comments
 (0)