Skip to content

Commit

Permalink
Replace expectException(, ) in integration tests
Browse files Browse the repository at this point in the history
expectException(); expectExceptionMessage()
  • Loading branch information
schmengler committed Sep 27, 2017
1 parent d2e0d44 commit 485cd57
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,11 @@ public function testGetListForAbsentSku()
'sku' => $productSku,
];
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
$this->expectException('SoapFault', 'Requested product doesn\'t exist');
$this->expectException('SoapFault');
$this->expectExceptionMessage('Requested product doesn\'t exist');
} else {
$this->expectException('Exception', '', 404);
$this->expectException('Exception');
$this->expectExceptionCode(404);
}
$this->_webApiCall($serviceInfo, $requestData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public function testCustomAttributeWrongType()
];

if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
$this->expectException('Exception', 'Attribute "meta_title" has invalid value.');
$this->expectException('Exception');
$this->expectExceptionMessage('Attribute "meta_title" has invalid value.');
} else {
$this->expectException('Exception', 'Attribute \"meta_title\" has invalid value.');
$this->expectException('Exception');
$this->expectExceptionMessage('Attribute \"meta_title\" has invalid value.');
}

$this->_webApiCall($serviceInfo, $this->getRequestData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,15 @@ public function testAddNegative($optionData)

if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
if (isset($optionDataPost['title']) && empty($optionDataPost['title'])) {
$this->expectException('SoapFault', 'Missed values for option required fields');
$this->expectException('SoapFault');
$this->expectExceptionMessage('Missed values for option required fields');
} else {
$this->expectException('SoapFault', 'Invalid option');
$this->expectException('SoapFault');
$this->expectExceptionMessage('Invalid option');
}
} else {
$this->expectException('Exception', '', 400);
$this->expectException('Exception');
$this->expectExceptionMessage('', 400);
}
$this->_webApiCall($serviceInfo, ['option' => $optionDataPost]);
}
Expand Down Expand Up @@ -406,7 +409,9 @@ public function testUpdateNegative($optionData, $message)
],
];

$this->expectException('Exception', $message, 400);
$this->expectException('Exception');
$this->expectExceptionMessage($message);
$this->expectExceptionCode(400);
$this->_webApiCall($serviceInfo, ['option' => $optionData]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ public function testDeleteAllStoreCode($fixtureProduct)
{
$sku = $fixtureProduct[ProductInterface::SKU];
$this->saveProduct($fixtureProduct);
$this->expectException('Exception', 'Requested product doesn\'t exist');
$this->expectException('Exception');
$this->expectExceptionMessage('Requested product doesn\'t exist');

// Delete all with 'all' store code
$this->deleteProduct($sku);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function testExceptionSoapInternalError()
'operation' => 'testModule3ErrorV1ServiceException',
],
];
$this->expectException('SoapFault', 'Generic service exception');
$this->expectException('SoapFault');
$this->expectExceptionMessage('Generic service exception');
$this->_webApiCall($serviceInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public function getAsConfigFileDataProvider()
*/
public function testGetAsConfigFileException($settingName, $expectedExceptionMsg)
{
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $expectedExceptionMsg);
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
$this->expectExceptionMessage($expectedExceptionMsg);
$this->_object->getAsConfigFile($settingName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function testGetRuleUnsupportedType()
*/
public function testGetPatternDirsException($type, array $overriddenParams, $expectedErrorMessage)
{
$this->expectException('InvalidArgumentException', $expectedErrorMessage);
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($expectedErrorMessage);
$params = $overriddenParams + $this->defaultParams;
$this->model->getRule($type)->getPatternDirs($params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ public function testAddContainerInvalidHtmlTag()
$msg = 'Html tag "span" is forbidden for usage in containers. ' .
'Consider to use one of the allowed: aside, dd, div, dl, fieldset, main, nav, ' .
'header, footer, ol, p, section, table, tfoot, ul.';
$this->expectException(\Magento\Framework\Exception\LocalizedException::class, $msg);
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
$this->expectExceptionMessage($msg);
$this->_layout->addContainer('container', 'Container', ['htmlTag' => 'span']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function testRatingEdit()
*/
public function testRatingSaveWithError()
{
$this->expectException('Exception', 'Rolled back transaction has not been completed correctly');
$this->expectException('Exception');
$this->expectExceptionMessage('Rolled back transaction has not been completed correctly');
$rating = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Review\Model\Rating::class
);
Expand Down

0 comments on commit 485cd57

Please sign in to comment.