@@ -278,8 +278,6 @@ public function testUpdateConfigurableProductLinks()
278
278
279
279
/**
280
280
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
281
- * @expectedException \Exception
282
- * @expectedExceptionMessage Product with id "%1" does not exist.
283
281
*/
284
282
public function testUpdateConfigurableProductLinksWithNonExistingProduct ()
285
283
{
@@ -292,13 +290,26 @@ public function testUpdateConfigurableProductLinksWithNonExistingProduct()
292
290
$ response [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ]['configurable_product_links ' ] = [
293
291
$ productId1 , $ nonExistingId
294
292
];
295
- $ this ->saveProduct ($ response );
293
+
294
+ $ expectedMessage = 'Product with id "%1" does not exist. ' ;
295
+ try {
296
+ $ this ->saveProduct ($ response );
297
+ $ this ->fail ("Expected exception " );
298
+ } catch (\SoapFault $ e ) {
299
+ $ this ->assertContains (
300
+ $ expectedMessage ,
301
+ $ e ->getMessage (),
302
+ "SoapFault does not contain expected message. "
303
+ );
304
+ } catch (\Exception $ e ) {
305
+ $ errorObj = $ this ->processRestExceptionResult ($ e );
306
+ $ this ->assertEquals ($ expectedMessage , $ errorObj ['message ' ]);
307
+ $ this ->assertEquals (['0 ' => '999 ' ], $ errorObj ['parameters ' ]);
308
+ }
296
309
}
297
310
298
311
/**
299
312
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
300
- * @expectedException \Exception
301
- * @expectedExceptionMessage Products "%1" and %2 have the same set of attribute values.
302
313
*/
303
314
public function testUpdateConfigurableProductLinksWithDuplicateAttributes ()
304
315
{
@@ -323,7 +334,22 @@ public function testUpdateConfigurableProductLinksWithDuplicateAttributes()
323
334
$ response [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY ]['configurable_product_links ' ] = [
324
335
$ productId1 , $ productId2
325
336
];
326
- $ this ->saveProduct ($ response );
337
+
338
+ $ expectedMessage = 'Products "%1" and %2 have the same set of attribute values. ' ;
339
+ try {
340
+ $ this ->saveProduct ($ response );
341
+ $ this ->fail ("Expected exception " );
342
+ } catch (\SoapFault $ e ) {
343
+ $ this ->assertContains (
344
+ $ expectedMessage ,
345
+ $ e ->getMessage (),
346
+ "SoapFault does not contain expected message. "
347
+ );
348
+ } catch (\Exception $ e ) {
349
+ $ errorObj = $ this ->processRestExceptionResult ($ e );
350
+ $ this ->assertEquals ($ expectedMessage , $ errorObj ['message ' ]);
351
+ $ this ->assertEquals (['0 ' => 20 , '1 ' => 10 ], $ errorObj ['parameters ' ]);
352
+ }
327
353
}
328
354
329
355
/**
0 commit comments