@@ -184,22 +184,51 @@ public function testDeleteNoSuchEntityException()
184
184
185
185
/**
186
186
* @dataProvider deleteSystemOrRootDataProvider
187
+ *
188
+ * @param int $categoryId
189
+ * @param string $exceptionMsg
190
+ * @return void
187
191
*/
188
- public function testDeleteSystemOrRoot ()
192
+ public function testDeleteSystemOrRoot (int $ categoryId , string $ exceptionMsg ): void
189
193
{
190
194
$ this ->expectException (\Exception::class);
195
+ $ this ->expectExceptionMessage ($ exceptionMsg );
191
196
192
- $ this ->deleteCategory ($ this -> modelId );
197
+ $ this ->deleteCategory ($ categoryId );
193
198
}
194
199
195
- public function deleteSystemOrRootDataProvider ()
200
+ /**
201
+ * @return array
202
+ */
203
+ public function deleteSystemOrRootDataProvider (): array
196
204
{
197
205
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
+ ],
200
214
];
201
215
}
202
216
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
+
203
232
/**
204
233
* @magentoApiDataFixture Magento/Catalog/_files/category.php
205
234
*/
0 commit comments