Skip to content

Commit c557360

Browse files
schmenglerMastiuhin Oleksandr
authored and
Mastiuhin Oleksandr
committed
Replace expectException(, ) in integration tests
expectException(); expectExceptionMessage() (cherry picked from commit 485cd57)
1 parent 948e5fa commit c557360

File tree

9 files changed

+29
-18
lines changed

9 files changed

+29
-18
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,13 @@ public function testGetListForAbsentSku()
610610
'sku' => $productSku,
611611
];
612612
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
613-
$this->expectException(
614-
'SoapFault',
613+
$this->expectException('SoapFault');
614+
$this->expectExceptionMessage(
615615
"The product that was requested doesn't exist. Verify the product and try again."
616616
);
617617
} else {
618-
$this->expectException('Exception', '', 404);
618+
$this->expectException('Exception');
619+
$this->expectExceptionCode(404);
619620
}
620621
$this->_webApiCall($serviceInfo, $requestData);
621622
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ public function testCustomAttributeWrongType()
4343
];
4444

4545
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
46-
$this->expectException('Exception', 'Attribute "meta_title" has invalid value.');
46+
$this->expectException('Exception');
47+
$this->expectExceptionMessage('Attribute "meta_title" has invalid value.');
4748
} else {
48-
$this->expectException('Exception', 'Attribute \"meta_title\" has invalid value.');
49+
$this->expectException('Exception');
50+
$this->expectExceptionMessage('Attribute \"meta_title\" has invalid value.');
4951
}
5052

5153
$this->_webApiCall($serviceInfo, $this->getRequestData());

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,15 @@ public function testAddNegative($optionData)
209209

210210
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
211211
if (isset($optionDataPost['title']) && empty($optionDataPost['title'])) {
212-
$this->expectException('SoapFault', 'Missed values for option required fields');
212+
$this->expectException('SoapFault');
213+
$this->expectExceptionMessage('Missed values for option required fields');
213214
} else {
214-
$this->expectException('SoapFault', 'Invalid option');
215+
$this->expectException('SoapFault');
216+
$this->expectExceptionMessage('Invalid option');
215217
}
216218
} else {
217-
$this->expectException('Exception', '', 400);
219+
$this->expectException('Exception');
220+
$this->expectExceptionMessage('', 400);
218221
}
219222
$this->_webApiCall($serviceInfo, ['option' => $optionDataPost]);
220223
}
@@ -404,7 +407,9 @@ public function testUpdateNegative($optionData, $message)
404407
],
405408
];
406409

407-
$this->expectException('Exception', $message, 400);
410+
$this->expectException('Exception');
411+
$this->expectExceptionMessage($message);
412+
$this->expectExceptionCode(400);
408413
$this->_webApiCall($serviceInfo, ['option' => $optionData]);
409414
}
410415

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,8 @@ public function testDeleteAllStoreCode($fixtureProduct)
314314
{
315315
$sku = $fixtureProduct[ProductInterface::SKU];
316316
$this->saveProduct($fixtureProduct);
317-
$this->expectException(
318-
'Exception',
319-
"The product that was requested doesn't exist. Verify the product and try again."
320-
);
317+
$this->expectException('Exception');
318+
$this->expectExceptionMessage("The product that was requested doesn't exist. Verify the product and try again.");
321319

322320
// Delete all with 'all' store code
323321
$this->deleteProduct($sku);

dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public function testExceptionSoapInternalError()
7373
'operation' => 'testModule3ErrorV1ServiceException',
7474
],
7575
];
76-
$this->expectException('SoapFault', 'Generic service exception');
76+
$this->expectException('SoapFault');
77+
$this->expectExceptionMessage('Generic service exception');
7778
$this->_webApiCall($serviceInfo);
7879
}
7980

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ public function getAsConfigFileDataProvider()
199199
*/
200200
public function testGetAsConfigFileException($settingName, $expectedExceptionMsg)
201201
{
202-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $expectedExceptionMsg);
202+
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
203+
$this->expectExceptionMessage($expectedExceptionMsg);
203204
$this->_object->getAsConfigFile($settingName);
204205
}
205206

dev/tests/integration/testsuite/Magento/Framework/View/Design/Fallback/RulePoolTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public function testGetRuleUnsupportedType()
7474
*/
7575
public function testGetPatternDirsException($type, array $overriddenParams, $expectedErrorMessage)
7676
{
77-
$this->expectException('InvalidArgumentException', $expectedErrorMessage);
77+
$this->expectException('InvalidArgumentException');
78+
$this->expectExceptionMessage($expectedErrorMessage);
7879
$params = $overriddenParams + $this->defaultParams;
7980
$this->model->getRule($type)->getPatternDirs($params);
8081
}

dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ public function testAddContainerInvalidHtmlTag()
275275
$msg = 'Html tag "span" is forbidden for usage in containers. ' .
276276
'Consider to use one of the allowed: aside, dd, div, dl, fieldset, main, nav, ' .
277277
'header, footer, ol, p, section, table, tfoot, ul.';
278-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $msg);
278+
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
279+
$this->expectExceptionMessage($msg);
279280
$this->_layout->addContainer('container', 'Container', ['htmlTag' => 'span']);
280281
}
281282

dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/RatingTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function testRatingEdit()
7777
*/
7878
public function testRatingSaveWithError()
7979
{
80-
$this->expectException('Exception', 'Rolled back transaction has not been completed correctly');
80+
$this->expectException('Exception');
81+
$this->expectExceptionMessage('Rolled back transaction has not been completed correctly');
8182
$rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
8283
\Magento\Review\Model\Rating::class
8384
);

0 commit comments

Comments
 (0)