diff --git a/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php b/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php index 92c549c3edfef..a2e827c4a9938 100755 --- a/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php @@ -21,7 +21,8 @@ public function testBeforeSave($value, $errorMessage = null) \Magento\Backend\Model\Config\SessionLifetime\BackendModel::class ); if ($errorMessage !== null) { - $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $errorMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage($errorMessage); } $model->setValue($value); $object = $model->beforeSave(); diff --git a/app/code/Magento/Captcha/Test/Unit/Model/CaptchaFactoryTest.php b/app/code/Magento/Captcha/Test/Unit/Model/CaptchaFactoryTest.php index bc2f8d02e2544..2c1337038b91c 100644 --- a/app/code/Magento/Captcha/Test/Unit/Model/CaptchaFactoryTest.php +++ b/app/code/Magento/Captcha/Test/Unit/Model/CaptchaFactoryTest.php @@ -54,12 +54,10 @@ public function testCreateNegative() $this->returnValue($defaultCaptchaMock) ); - $this->expectException( - 'InvalidArgumentException', - 'Magento\Captcha\Model\\' . ucfirst( + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Magento\Captcha\Model\\' . ucfirst( $captchaType - ) . ' does not implement \Magento\Captcha\Model\CaptchaInterface' - ); + ) . ' does not implement \Magento\Captcha\Model\CaptchaInterface'); $this->assertEquals($defaultCaptchaMock, $this->_model->create($captchaType, 'form_id')); } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php index 9d0ab628a6450..53d2770f19cc8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php @@ -27,11 +27,9 @@ protected function setUp() public function testCreateWithInvalidType() { - $this->expectException( - '\InvalidArgumentException', - \Magento\Framework\DataObject::class . ' does not implement ' . - \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class - ); + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage(\Magento\Framework\DataObject::class . ' does not implement ' . + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class); $this->_objectManagerMock->expects($this->never())->method('create'); $this->_model->create(\Magento\Framework\DataObject::class); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php index 1bc5e450ae153..d21b59716a044 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php @@ -255,7 +255,8 @@ public function testSaveWithException() */ public function testSaveWithValidateCategoryException($error, $expectedException, $expectedExceptionMessage) { - $this->expectException($expectedException, $expectedExceptionMessage); + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); $categoryId = 5; $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class); $this->extensibleDataObjectConverterMock @@ -284,7 +285,8 @@ public function saveWithValidateCategoryExceptionDataProvider() return [ [ true, \Magento\Framework\Exception\CouldNotSaveException::class, - 'Could not save category: Attribute "ValidateCategoryTest" is required.', + 'Could not save category: Attribute The "ValidateCategoryTest" attribute is required.' . + 'Enter and try again.', ], [ 'Something went wrong', \Magento\Framework\Exception\CouldNotSaveException::class, 'Could not save category: Something went wrong' diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php index eb5fdabe53303..c254557904da1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Eav/Action/FullTest.php @@ -48,7 +48,8 @@ public function testExecuteWithAdapterErrorThrowsException() $tableSwitcherMock ); - $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage($exceptionMessage); $model->execute(); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php index a01e9814b0579..1c0ea6ee1ed39 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopyConstructorFactoryTest.php @@ -27,8 +27,8 @@ protected function setUp() public function testCreateWithInvalidType() { - $this->expectException( - '\InvalidArgumentException', + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage( 'Magento\Framework\DataObject does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface' ); $this->_objectManagerMock->expects($this->never())->method('create'); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php index e1a19bf10ecd4..3590c96bd1532 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php @@ -44,7 +44,8 @@ public function testExecuteWithAdapterErrorThrowsException() ] ); - $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage($exceptionMessage); $model->execute(); } diff --git a/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php b/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php index 2174792d929a2..0c2c62ac62191 100644 --- a/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php +++ b/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php @@ -379,10 +379,8 @@ public function testGetCurrentPath($pathId, $expectedPath, $isExist) public function testGetCurrentPathThrowException() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - 'The directory PATH/wysiwyg is not writable by server.' - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage('The directory PATH is not writable by server.'); $this->directoryWriteMock->expects($this->once()) ->method('isExist') diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php index 805f6d042f94a..2fb9649fc61de 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php @@ -239,8 +239,8 @@ public function testGetResizeHeight() */ public function testDeleteDirectoryOverRoot() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage( sprintf('Directory %s is not under storage root path.', self::INVALID_DIRECTORY_OVER_ROOT) ); $this->imagesStorage->deleteDirectory(self::INVALID_DIRECTORY_OVER_ROOT); @@ -251,10 +251,9 @@ public function testDeleteDirectoryOverRoot() */ public function testDeleteRootDirectory() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - sprintf('We can\'t delete root directory %s right now.', self::STORAGE_ROOT_DIR) - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage(sprintf('We can\'t delete root directory %s right now.', self::STORAGE_ROOT_DIR)); + $this->imagesStorage->deleteDirectory(self::STORAGE_ROOT_DIR); } diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php index 4f53f1072e035..0b4d5f7ef15f7 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php @@ -128,7 +128,8 @@ public function testRenderCellTemplateWrongColumnName() $this->object->addColumn($wrongColumnName, $this->cellParameters); - $this->expectException('\Exception', 'Wrong column name specified.'); + $this->expectException('\Exception'); + $this->expectExceptionMessage('Wrong column name specified.'); $this->object->renderCellTemplate($columnName); } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php index 95e8246c6a3d3..df20db4a1d92a 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php @@ -31,10 +31,8 @@ public function testMap($sourceData, $resultData) public function testMapWithBadPath() { - $this->expectException( - 'InvalidArgumentException', - 'Invalid path in extends attribute of config/system/sections/section1 node' - ); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Invalid path in extends attribute of config/system/sections/section1 node'); $sourceData = [ 'config' => [ 'system' => ['sections' => ['section1' => ['extends' => 'nonExistentSection2']]], diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php index c671a5326c4de..058f9a380a27d 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php @@ -24,7 +24,8 @@ public function testConvertWithInvalidRelativePath() $exceptionMessage = sprintf('Invalid relative path %s in %s node', $relativePath, $nodePath); - $this->expectException('InvalidArgumentException', $exceptionMessage); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage($exceptionMessage); $this->_sut->convert($nodePath, $relativePath); } @@ -35,7 +36,8 @@ public function testConvertWithInvalidRelativePath() */ public function testConvertWithInvalidArguments($nodePath, $relativePath) { - $this->expectException('InvalidArgumentException', 'Invalid arguments'); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Invalid arguments'); $this->_sut->convert($nodePath, $relativePath); } diff --git a/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php index 2832e8e54e5f6..2ddbbd5ffe1e8 100644 --- a/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php @@ -280,7 +280,8 @@ public function testSetDataByPathEmpty() public function testSetDataByPathWrongDepth($path, $expectedException) { $expectedException = 'Allowed depth of configuration is 3 (
//). ' . $expectedException; - $this->expectException('\UnexpectedValueException', $expectedException); + $this->expectException('\UnexpectedValueException'); + $this->expectExceptionMessage($expectedException); $value = 'value'; $this->_model->setDataByPath($path, $value); } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php index 8f3f3979b8669..7ea55c51a5bb3 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php @@ -357,7 +357,8 @@ public function testGetListNotConfigurableProduct() */ public function testValidateNewOptionData($attributeId, $label, $optionValues, $msg) { - $this->expectException(\Magento\Framework\Exception\InputException::class, $msg); + $this->expectException(\Magento\Framework\Exception\InputException::class); + $this->expectExceptionMessage($msg); $optionValueMock = $this->getMockBuilder(\Magento\ConfigurableProduct\Api\Data\OptionValueInterface::class) ->setMethods(['getValueIndex', 'getPricingValue', 'getIsPercent']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php index 5b4a8d5b8a975..a3f1435f84d2f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php @@ -32,13 +32,15 @@ protected function setUp() public function testGetWithScalar() { - $this->expectException(\InvalidArgumentException::class, 'Provided argument is not an object'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Provided argument is not an object'); $this->model->getTags('scalar'); } public function testGetTagsWithObject() { - $this->expectException(\InvalidArgumentException::class, 'Provided argument must be a product'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Provided argument must be a product'); $this->model->getTags(new \stdClass()); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php index cf55928a6d30f..d6ed27d94481a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php @@ -757,19 +757,15 @@ public function testCreateAccountWithPasswordInputException( ->willReturn(iconv_strlen($password, 'UTF-8')); if ($testNumber == 1) { - $this->expectException( - \Magento\Framework\Exception\InputException::class, - 'The password needs at least ' . $minPasswordLength . ' characters. ' - . 'Create a new password and try again.' - ); + $this->expectException(\Magento\Framework\Exception\InputException::class); + $this->expectExceptionMessage('The password needs at least ' . $minPasswordLength . ' characters. ' + . 'Create a new password and try again.'); } if ($testNumber == 2) { - $this->expectException( - \Magento\Framework\Exception\InputException::class, - 'Minimum of different classes of characters in password is ' . $minCharacterSetsNum . - '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.' - ); + $this->expectException(\Magento\Framework\Exception\InputException::class); + $this->expectExceptionMessage('Minimum of different classes of characters in password is ' . $minCharacterSetsNum . + '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.'); } $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); @@ -787,10 +783,8 @@ public function testCreateAccountInputExceptionExtraLongPassword() ->with($password) ->willReturn(iconv_strlen($password, 'UTF-8')); - $this->expectException( - \Magento\Framework\Exception\InputException::class, - 'Please enter a password with at most 256 characters.' - ); + $this->expectException(\Magento\Framework\Exception\InputException::class); + $this->expectExceptionMessage('Please enter a password with at most 256 characters.'); $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock(); $this->accountManagement->createAccount($customer, $password); @@ -1568,10 +1562,8 @@ public function testChangePasswordException() ->with($email) ->willThrowException($exception); - $this->expectException( - \Magento\Framework\Exception\InvalidEmailOrPasswordException::class, - 'Invalid login or password.' - ); + $this->expectException(\Magento\Framework\Exception\InvalidEmailOrPasswordException::class); + $this->expectExceptionMessage('Invalid login or password.'); $this->accountManagement->changePassword($email, $currentPassword, $newPassword); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php index 4cea7ee22837d..408389182ae49 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php @@ -71,7 +71,8 @@ public function testLog($customerId, $data) $data = array_filter($data); if (!$data) { - $this->expectException('\InvalidArgumentException', 'Log data is empty'); + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage('Log data is empty'); $this->logger->log($customerId, $data); return; } diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php index 54ec26386f3bd..76b23e4e79ec2 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php @@ -29,7 +29,8 @@ protected function setUp() */ public function testConstructorException(array $configData, $expectedException) { - $this->expectException('InvalidArgumentException', $expectedException); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage($expectedException); new \Magento\Directory\Model\Currency\Import\Config($configData); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php index 79f601b154b73..222a1d0193eb8 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php @@ -44,7 +44,8 @@ public function testValidateWithExistingName($attributeSetName, $exceptionMessag { $this->_model->getResource()->expects($this->any())->method('validate')->will($this->returnValue(false)); - $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage($exceptionMessage); $this->_model->setAttributeSetName($attributeSetName); $this->_model->validate(); } diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/Config/FileIteratorTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/Config/FileIteratorTest.php index 38429328b4432..c5165cc16793c 100644 --- a/app/code/Magento/Email/Test/Unit/Model/Template/Config/FileIteratorTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/Template/Config/FileIteratorTest.php @@ -93,10 +93,8 @@ public function testIteratorNegative() { $filePath = $this->filePaths[0]; - $this->expectException( - 'UnexpectedValueException', - sprintf("Unable to determine a module, file '%s' belongs to.", $filePath) - ); + $this->expectException('UnexpectedValueException'); + $this->expectExceptionMessage(sprintf("Unable to determine a module, file '%s' belongs to.", $filePath)); $this->moduleDirResolverMock->expects($this->at(0)) ->method('getModuleName') diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php index 6ec3905fe4633..47c3ac1e7e450 100644 --- a/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php @@ -311,7 +311,8 @@ public function testGetterMethodUnknownField( array $fixtureFields = [], $argument = null ) { - $this->expectException('UnexpectedValueException', $expectedException); + $this->expectException('UnexpectedValueException'); + $this->expectExceptionMessage($expectedException); $dataStorage = $this->createPartialMock(\Magento\Email\Model\Template\Config\Data::class, ['get']); $dataStorage->expects( $this->atLeastOnce() diff --git a/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php b/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php index 36b0d77d1e1ae..badb69aa19fe4 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Oauth/TokenTest.php @@ -384,7 +384,8 @@ public function testValidateIfNotCallbackEstablishedAndNotValid() $this->validatorMock->expects($this->once())->method('isValid')->willReturn(false); $this->validatorMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->expectException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Oauth\Exception::class); + $this->expectExceptionMessage($exceptionMessage); $this->tokenModel->validate(); } @@ -402,7 +403,8 @@ public function testValidateIfSecretNotValid() $this->validatorKeyLengthMock->expects($this->once())->method('isValid')->willReturn(false); $this->validatorKeyLengthMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->expectException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Oauth\Exception::class); + $this->expectExceptionMessage($exceptionMessage); $this->tokenModel->validate(); } @@ -429,7 +431,8 @@ public function testValidateIfTokenNotValid() ] ); $this->validatorKeyLengthMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->expectException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Oauth\Exception::class); + $this->expectExceptionMessage($exceptionMessage); $this->tokenModel->validate(); } @@ -459,7 +462,8 @@ public function testValidateIfVerifierNotValid() ] ); $this->validatorKeyLengthMock->expects($this->once())->method('getMessages')->willReturn([$exceptionMessage]); - $this->expectException(\Magento\Framework\Oauth\Exception::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Oauth\Exception::class); + $this->expectExceptionMessage($exceptionMessage); $this->tokenModel->validate(); } diff --git a/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php b/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php index 875377776771d..966a6b293196f 100644 --- a/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php +++ b/app/code/Magento/Integration/Test/Unit/Oauth/OauthTest.php @@ -777,11 +777,9 @@ public function testBuildAuthorizationHeader() */ public function testMissingParamForBuildAuthorizationHeader($expectedMessage, $request) { - $this->expectException( - \Magento\Framework\Oauth\OauthInputException::class, - $expectedMessage, - 0 - ); + $this->expectException(\Magento\Framework\Oauth\OauthInputException::class); + $this->expectExceptionMessage($expectedMessage); + $this->expectExceptionCode(0); $requestUrl = 'http://www.example.com/endpoint'; $this->_oauth->buildAuthorizationHeader($request, $requestUrl); diff --git a/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php b/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php index eb1e3d3a91b92..dd18d9f256d93 100644 --- a/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php +++ b/app/code/Magento/Payment/Test/Unit/Block/Transparent/FormTest.php @@ -290,10 +290,8 @@ public function testGetMethodSuccess() public function testGetMethodNotTransparentInterface() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - __('We cannot retrieve the transparent payment method model object.') - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage((string)__('We cannot retrieve the transparent payment method model object.')); $methodMock = $this->getMockBuilder(\Magento\Payment\Model\MethodInterface::class) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php index 10c432da77202..2ef08e4d4226b 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php @@ -132,7 +132,9 @@ protected function _invokeNvpProperty(\Magento\Paypal\Model\Api\Nvp $nvpObject, public function testCall($response, $processableErrors, $exception, $exceptionMessage = '', $exceptionCode = null) { if (isset($exception)) { - $this->expectException($exception, $exceptionMessage, $exceptionCode); + $this->expectException($exception); + $this->expectExceptionMessage($exceptionMessage); + $this->expectExceptionCode($exceptionCode); } $this->curl->expects($this->once()) ->method('read') diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php index b24ca640dea2d..ec2648b89612e 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Response/Handler/HandlerCompositeTest.php @@ -23,10 +23,8 @@ public function testConstructorSuccess() public function testConstructorException() { - $this->expectException( - 'LogicException', - 'Type mismatch. Expected type: HandlerInterface. Actual: string, Code: weird_handler' - ); + $this->expectException('LogicException'); + $this->expectExceptionMessage('Type mismatch. Expected type: HandlerInterface. Actual: string, Code: weird_handler'); new HandlerComposite( ['weird_handler' => 'some value'] diff --git a/app/code/Magento/Rule/Test/Unit/Model/ConditionFactoryTest.php b/app/code/Magento/Rule/Test/Unit/Model/ConditionFactoryTest.php index d8c0cc470f55e..f78ee4f345d0d 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/ConditionFactoryTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/ConditionFactoryTest.php @@ -78,7 +78,8 @@ public function testCreateExceptionClass() ->expects($this->never()) ->method('create'); - $this->expectException(\InvalidArgumentException::class, 'Class does not exist'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Class does not exist'); $this->conditionFactory->create($type); } @@ -92,7 +93,8 @@ public function testCreateExceptionType() ->method('create') ->with($type) ->willReturn(new \stdClass()); - $this->expectException(\InvalidArgumentException::class, 'Class does not implement condition interface'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Class does not implement condition interface'); $this->conditionFactory->create($type); } } diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php index ebdc10830f33f..31536e1be3d2e 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/CouponRepositoryTest.php @@ -150,7 +150,8 @@ public function testSaveWithExceptions($exceptionObject, $exceptionName, $except $this->resource->expects($this->once())->method('save')->with($coupon) ->willThrowException($exceptionObject); } - $this->expectException($exceptionName, $exceptionMessage); + $this->expectException($exceptionName); + $this->expectExceptionMessage($exceptionMessage); $this->model->save($coupon); } diff --git a/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php b/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php index 8d98d8145f17e..c5326da45005e 100644 --- a/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/SecurityManagerTest.php @@ -126,9 +126,9 @@ public function testConstructorException() { $securityChecker = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - __('Incorrect Security Checker class. It has to implement SecurityCheckerInterface') + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage( + (string)__('Incorrect Security Checker class. It has to implement SecurityCheckerInterface') ); $this->model->__construct( diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php index f7aa65f842b91..c34e64f469f77 100644 --- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php +++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php @@ -121,10 +121,8 @@ public function testCreateCaseWithFailedApiCall() ->method('makeApiCall') ->willThrowException(new ApiCallException($apiCallFailureMessage)); - $this->expectException( - GatewayException::class, - $apiCallFailureMessage - ); + $this->expectException(GatewayException::class); + $this->expectExceptionMessage($apiCallFailureMessage); $this->gateway->createCase($dummyOrderId); } @@ -197,10 +195,8 @@ public function testSubmitCaseForGuaranteeWithFailedApiCall() ->method('makeApiCall') ->willThrowException(new ApiCallException($apiCallFailureMessage)); - $this->expectException( - GatewayException::class, - $apiCallFailureMessage - ); + $this->expectException(GatewayException::class); + $this->expectExceptionMessage($apiCallFailureMessage); $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId); $this->assertEquals('Api call failed', $result); } diff --git a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php index 82a1f1803e903..e12edf0c683e9 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php @@ -307,7 +307,8 @@ public function testSaveThrowsExceptionIfCannotSaveTitles($expectedException, $e ->with($rateTitles) ->willThrowException($expectedException); $this->rateRegistryMock->expects($this->never())->method('registerTaxRate')->with($rateMock); - $this->expectException($exceptionType, $exceptionMessage); + $this->expectException($exceptionType); + $this->expectExceptionMessage($exceptionMessage); $this->model->save($rateMock); } diff --git a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateTest.php b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateTest.php index 4edb0328b73c2..7284eb46ea9d8 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateTest.php @@ -47,7 +47,8 @@ protected function setUp() */ public function testExceptionOfValidation($exceptionMessage, $data) { - $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage($exceptionMessage); $rate = $this->objectHelper->getObject( \Magento\Tax\Model\Calculation\Rate::class, ['resource' => $this->resourceMock] diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php index eb107c248880b..ee611b5320a8a 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/FactoryTest.php @@ -70,10 +70,8 @@ public function testCreateWithWrongClassType() $taxClassFactory = new \Magento\Tax\Model\TaxClass\Factory($objectManager); - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - sprintf('Invalid type of tax class "%s"', $wrongClassType) - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage(sprintf('Invalid type of tax class "%s"', $wrongClassType)); $taxClassFactory->create($classMock); } } diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php index 182e1b43d786c..f4151cd18ba66 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php @@ -163,7 +163,8 @@ public function testSaveWithExceptions($exceptionObject, $exceptionName, $except ->willThrowException($exceptionObject); $this->taxRuleRegistry->expects($this->never())->method('registerTaxRule'); - $this->expectException($exceptionName, $exceptionMessage); + $this->expectException($exceptionName); + $this->expectExceptionMessage($exceptionMessage); $this->model->save($rule); } diff --git a/app/code/Magento/Theme/Test/Unit/Observer/CleanThemeRelatedContentObserverTest.php b/app/code/Magento/Theme/Test/Unit/Observer/CleanThemeRelatedContentObserverTest.php index 0eaa509685616..f1f4664c8541d 100644 --- a/app/code/Magento/Theme/Test/Unit/Observer/CleanThemeRelatedContentObserverTest.php +++ b/app/code/Magento/Theme/Test/Unit/Observer/CleanThemeRelatedContentObserverTest.php @@ -105,7 +105,8 @@ public function testCleanThemeRelatedContentException() $this->themeConfig->expects($this->any())->method('isThemeAssignedToStore')->with($themeMock)->willReturn(true); - $this->expectException(\Magento\Framework\Exception\LocalizedException::class, 'Theme isn\'t deletable.'); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage('Theme isn\'t deletable.'); $this->themeObserver->execute($observerMock); } diff --git a/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php b/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php index 414f52037542d..e569688eaa8c6 100644 --- a/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php +++ b/app/code/Magento/Ui/Test/Unit/Model/ManagerTest.php @@ -152,9 +152,9 @@ public function testGetReader() public function testPrepareDataWithoutName() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - __('The "" UI component element name is invalid. Verify the name and try again.') + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage( + (string)__('The "" UI component element name is invalid. Verify the name and try again.') ); $this->manager->prepareData(null); } diff --git a/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php b/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php index 717b2d7e04418..be3c1c60da5bc 100644 --- a/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php +++ b/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php @@ -122,10 +122,12 @@ public function testGetByIdWithException() ->method('load') ->with($this->bookmarkMock, $notExistsBookmarkId) ->willReturn($this->bookmarkMock); - $this->expectException( - \Magento\Framework\Exception\NoSuchEntityException::class, - __('The bookmark with "%1" ID doesn\'t exist. Verify your information and try again.', $notExistsBookmarkId) + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $exceptionMessage = (string)__( + 'The bookmark with "%1" ID doesn\'t exist. Verify your information and try again.', + $notExistsBookmarkId ); + $this->expectExceptionMessage($exceptionMessage); $this->bookmarkRepository->getById($notExistsBookmarkId); } diff --git a/app/code/Magento/User/Test/Unit/Model/UserTest.php b/app/code/Magento/User/Test/Unit/Model/UserTest.php index c00325da00c37..75fe99445fd5d 100644 --- a/app/code/Magento/User/Test/Unit/Model/UserTest.php +++ b/app/code/Magento/User/Test/Unit/Model/UserTest.php @@ -350,11 +350,9 @@ public function testVerifyIdentityInactiveRecord() ->with($password, $this->model->getPassword()) ->willReturn(true); $this->model->setIsActive(false); - $this->expectException( - \Magento\Framework\Exception\AuthenticationException::class, - 'The account sign-in was incorrect or your account is disabled temporarily. ' - . 'Please wait and try again later.' - ); + $this->expectException(\Magento\Framework\Exception\AuthenticationException::class); + $this->expectExceptionMessage('The account sign-in was incorrect or your account is disabled temporarily. ' + . 'Please wait and try again later.'); $this->model->verifyIdentity($password); } @@ -371,10 +369,8 @@ public function testVerifyIdentityNoAssignedRoles() ->willReturn(true); $this->model->setIsActive(true); $this->resourceMock->expects($this->once())->method('hasAssigned2Role')->willReturn(false); - $this->expectException( - \Magento\Framework\Exception\AuthenticationException::class, - 'More permissions are needed to access this.' - ); + $this->expectException(\Magento\Framework\Exception\AuthenticationException::class); + $this->expectExceptionMessage('More permissions are needed to access this.'); $this->model->verifyIdentity($password); } @@ -782,16 +778,14 @@ public function testPerformIdentityCheck($verifyIdentityResult, $lockExpires) ->willReturnSelf(); if ($lockExpires) { - $this->expectException( - \Magento\Framework\Exception\State\UserLockedException::class, - __('Your account is temporarily disabled. Please try again later.') - ); + $this->expectException(\Magento\Framework\Exception\State\UserLockedException::class); + $this->expectExceptionMessage((string)__('Your account is temporarily disabled. Please try again later.')); } if (!$verifyIdentityResult) { - $this->expectException( - \Magento\Framework\Exception\AuthenticationException::class, - __('The password entered for the current user is invalid. Verify the password and try again.') + $this->expectException(\Magento\Framework\Exception\AuthenticationException::class); + $this->expectExceptionMessage( + (string)__('The password entered for the current user is invalid. Verify the password and try again.') ); } diff --git a/app/code/Magento/Webapi/Test/Unit/ExceptionTest.php b/app/code/Magento/Webapi/Test/Unit/ExceptionTest.php index f4ba35194725d..c3761c4e24862 100644 --- a/app/code/Magento/Webapi/Test/Unit/ExceptionTest.php +++ b/app/code/Magento/Webapi/Test/Unit/ExceptionTest.php @@ -43,7 +43,8 @@ public function testConstruct() */ public function testConstructInvalidHttpCode($httpCode) { - $this->expectException('InvalidArgumentException', "The specified HTTP code \"{$httpCode}\" is invalid."); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage("The specified HTTP code \"{$httpCode}\" is invalid."); /** Create \Magento\Framework\Webapi\Exception object with invalid code. */ /** Valid codes range is from 400 to 599. */ new \Magento\Framework\Webapi\Exception(__('Message'), 0, $httpCode); diff --git a/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php index dea5ae513ca31..c264bbca83b78 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php @@ -80,7 +80,8 @@ public function testValidate($data, $expected) ->will($this->returnValue($taxes)); // Exception caught - $this->expectException('Exception', $expected); + $this->expectException('Exception'); + $this->expectExceptionMessage($expected); $modelMock->validate($productMock); } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php index 0a990ab8d6a6b..9a6520a3ab458 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php @@ -610,12 +610,13 @@ public function testGetListForAbsentSku() 'sku' => $productSku, ]; if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { - $this->expectException( - 'SoapFault', + $this->expectException('SoapFault'); + $this->expectExceptionMessage( "The product that was requested doesn't exist. Verify the product and try again." ); } else { - $this->expectException('Exception', '', 404); + $this->expectException('Exception'); + $this->expectExceptionCode(404); } $this->_webApiCall($serviceInfo, $requestData); } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomAttributeWrongTypeTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomAttributeWrongTypeTest.php index 2dc8d19777898..19b0757439077 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomAttributeWrongTypeTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomAttributeWrongTypeTest.php @@ -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()); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php index 895d4b992301d..10693e6b15e41 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php @@ -217,7 +217,7 @@ public function testAddNegative($optionData) } } else { $this->expectException('Exception'); - $this->expectExceptionMessage('', 400); + $this->expectExceptionMessage(400); } $this->_webApiCall($serviceInfo, ['option' => $optionDataPost]); } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php index 4f430d19a0a97..bfb1e6743f9cc 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php @@ -314,10 +314,8 @@ public function testDeleteAllStoreCode($fixtureProduct) { $sku = $fixtureProduct[ProductInterface::SKU]; $this->saveProduct($fixtureProduct); - $this->expectException( - 'Exception', - "The product that was requested doesn't exist. Verify the product and try again." - ); + $this->expectException('Exception'); + $this->expectExceptionMessage("The product that was requested doesn't exist. Verify the product and try again."); // Delete all with 'all' store code $this->deleteProduct($sku); diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php index 53e0edc3d35b7..7a57d82be127f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.php @@ -114,10 +114,8 @@ public function testDeleteAddress() $response = $this->_webApiCall($serviceInfo, $requestData); $this->assertTrue($response, 'Expected response should be true.'); - $this->expectException( - \Magento\Framework\Exception\NoSuchEntityException::class, - 'No such entity with addressId = 1' - ); + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $this->expectExceptionMessage('No such entity with addressId = 1'); $this->addressRepository->getById($fixtureAddressId); } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index 8da91a3dffc0e..8f84f485fc2ae 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -217,10 +217,8 @@ public function testDeleteCustomer() $this->assertTrue($response); //Verify if the customer is deleted - $this->expectException( - \Magento\Framework\Exception\NoSuchEntityException::class, - sprintf("No such entity with customerId = %s", $customerData[Customer::ID]) - ); + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $this->expectExceptionMessage(sprintf("No such entity with customerId = %s", $customerData[Customer::ID])); $this->_getCustomerData($customerData[Customer::ID]); } diff --git a/dev/tests/api-functional/testsuite/Magento/Framework/Model/Entity/HydratorTest.php b/dev/tests/api-functional/testsuite/Magento/Framework/Model/Entity/HydratorTest.php index 74e987647493b..94070dd9190fc 100644 --- a/dev/tests/api-functional/testsuite/Magento/Framework/Model/Entity/HydratorTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Framework/Model/Entity/HydratorTest.php @@ -100,10 +100,8 @@ public function testDelete() /** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */ $customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class); - $this->expectException( - NoSuchEntityException::class, - "No such entity with customerId = {$fixtureCustomerId}" - ); + $this->expectException(NoSuchEntityException::class); + $this->expectExceptionMessage("No such entity with customerId = {$fixtureCustomerId}"); $customerRepository->getById($fixtureCustomerId); } diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php index c4e052e11310e..1476e6b31912b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php @@ -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); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php index aefe51f6ab37c..9964ec7f8c508 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php @@ -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((string)$expectedExceptionMsg); $this->_object->getAsConfigFile($settingName); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php index 8c9eaf5c34ab7..e7a2d17586a93 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php @@ -78,9 +78,11 @@ public function testRunValidationException() */ public function testLargeSizeFile() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - sprintf('The file you uploaded is larger than %s Megabytes allowed by server', $this->maxFileSizeInMb) + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $exceptionMessage = 'The file was too big and couldn\'t be uploaded. Use a file smaller than %s MBs and try ' . + 'to upload again.'; + $this->expectExceptionMessage( + sprintf($exceptionMessage, $this->maxFileSizeInMb) ); $this->prepareEnv(); $_SERVER['CONTENT_LENGTH'] = $this->maxFileSize + 1; @@ -152,8 +154,8 @@ public function testException() */ public function testInvalidateFile() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage( "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" @@ -167,6 +169,13 @@ public function testInvalidateFile() \Zend_File_Transfer_Adapter_Http::class, ['isValid', 'getErrors', 'getFileInfo', 'isUploaded'] ); + $httpAdapterMock->expects($this->once()) + ->method('getFileInfo') + ->willReturn([ + 'options_1_file' => [ + 'name' => 'test.jpg' + ] + ]); $httpAdapterMock->expects($this->once()) ->method('isValid') ->willReturn(false); @@ -217,10 +226,8 @@ public function testEmptyFile() { $this->prepareEnvForEmptyFile(); - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - 'The file is empty. Select another file and try again.' - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage('The file is empty. Select another file and try again.'); $httpAdapterMock = $this->createPartialMock(\Zend_File_Transfer_Adapter_Http::class, ['isValid']); $httpAdapterMock->expects($this->once())->method('isValid')->will($this->returnValue(true)); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php index eafe09f803166..41556d5558006 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php @@ -54,8 +54,8 @@ protected function setUp() */ public function testExceptionWithErrors() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage( "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" @@ -88,8 +88,8 @@ public function testExceptionWithErrors() */ public function testExceptionWithoutErrors() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage( "The product's required option(s) weren't entered. Make sure the options are entered and try again." ); diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php index a4dabdbf1615a..a0cac124bea07 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php @@ -204,10 +204,8 @@ public function testGenerateUrlRewritesWithSaveHistory() */ public function testGenerateUrlRewritesWithIncorrectUrlKey($urlKey) { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - 'Invalid URL key' - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage('Invalid URL key'); /** @var \Magento\Catalog\Api\CategoryRepositoryInterface $repository */ $repository = $this->objectManager->get(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $category = $repository->get(3); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Model/CartTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Model/CartTest.php index ed82831f25f0e..25be9ba0c12b4 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Model/CartTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Model/CartTest.php @@ -34,10 +34,8 @@ protected function setUp() */ public function testAddProductWithLowerQty() { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - 'The fewest you may purchase is 3' - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage('The fewest you may purchase is 3'); $product = $this->productRepository->get('simple'); $this->cart->addProduct($product->getId(), ['qty' => 1]); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php index fe9037e4ffd2b..1af093bea06cc 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php @@ -393,10 +393,8 @@ public function testDelete() $customer = $this->customerRepository->get($fixtureCustomerEmail); $this->customerRepository->delete($customer); /** Ensure that customer was deleted */ - $this->expectException( - \Magento\Framework\Exception\NoSuchEntityException::class, - 'No such entity with email = customer@example.com, websiteId = 1' - ); + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $this->expectExceptionMessage('No such entity with email = customer@example.com, websiteId = 1'); $this->customerRepository->get($fixtureCustomerEmail); } @@ -411,10 +409,8 @@ public function testDeleteById() $fixtureCustomerId = 1; $this->customerRepository->deleteById($fixtureCustomerId); /** Ensure that customer was deleted */ - $this->expectException( - \Magento\Framework\Exception\NoSuchEntityException::class, - 'No such entity with email = customer@example.com, websiteId = 1' - ); + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $this->expectExceptionMessage('No such entity with email = customer@example.com, websiteId = 1'); $this->customerRepository->get($fixtureCustomerEmail); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php index 2171f8fdf7351..c0cb63e30f69d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php @@ -57,8 +57,8 @@ public function testCreate() public function testCreateWithLogicException() { - $this->expectException( - 'LogicException', + $this->expectException('LogicException'); + $this->expectExceptionMessage( "Class 'Magento\\Framework\\Api\\ExtensionAttributesFactoryTest' must implement an interface, " . "which extends from 'Magento\\Framework\\Api\\ExtensibleDataInterface'" ); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php index 3e90aa67f464a..b2b3e4c48124e 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php @@ -182,6 +182,13 @@ public function testSettingInvalidCookieLifetime() $this->assertEquals($preVal, $model->getCookieLifetime()); } + public function testWrongMethodCall() + { + $this->expectException('\BadMethodCallException'); + $this->expectExceptionMessage('Method "methodThatNotExist" does not exist in Magento\Framework\Session\Config'); + $this->_model->methodThatNotExist(); + } + public function testSettingInvalidCookieLifetime2() { $model = $this->getModel(); diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Design/Fallback/RulePoolTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Design/Fallback/RulePoolTest.php index 1500c91478a4a..c586c68b74573 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/Design/Fallback/RulePoolTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Design/Fallback/RulePoolTest.php @@ -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); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php index c014b517f6463..66e8eb3e453f9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php @@ -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']); } diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php index ecd8b62b122d4..39db5b1572cb7 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php @@ -323,10 +323,8 @@ public function testAddProductUpdateItem() $quote->setTotalsCollectedFlag(false)->collectTotals(); $this->assertEquals(1, $quote->getItemsQty()); - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - 'We don\'t have as many "Simple Product" as you requested.' - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage('We don\'t have as many "Simple Product" as you requested.'); $updateParams['qty'] = $productStockQty + 1; $quote->updateItem($updateParams['id'], $updateParams); } @@ -441,10 +439,8 @@ public function testAddedProductToQuoteIsSalable() /** @var \Magento\Quote\Model\Quote $quote */ $product = $productRepository->getById($productId, false, null, true); - $this->expectException( - LocalizedException::class, - 'Product that you are trying to add is not available.' - ); + $this->expectException(LocalizedException::class); + $this->expectExceptionMessage('Product that you are trying to add is not available.'); $quote = $objectManager->create(\Magento\Quote\Model\Quote::class); $quote->addProduct($product); diff --git a/dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/RatingTest.php b/dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/RatingTest.php index c88bd5ed7cf77..7801cb2c78c24 100644 --- a/dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/RatingTest.php +++ b/dev/tests/integration/testsuite/Magento/Review/Model/ResourceModel/RatingTest.php @@ -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 ); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php index 2f95e11a4536b..d2dbcea3f70b0 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/ClassTest.php @@ -112,11 +112,9 @@ public function testCheckClassCanBeDeletedCustomerClassUsedInTaxRule() /** @var $model \Magento\Tax\Model\ClassModel */ $model = $this->_objectManager->create(\Magento\Tax\Model\ClassModel::class)->load($customerClasses[0]); - $this->expectException( - \Magento\Framework\Exception\CouldNotDeleteException::class, - 'You cannot delete this tax class because it is used in' . - ' Tax Rules. You have to delete the rules it is used in first.' - ); + $this->expectException(\Magento\Framework\Exception\CouldNotDeleteException::class); + $this->expectExceptionMessage('You cannot delete this tax class because it is used in' . + ' Tax Rules. You have to delete the rules it is used in first.'); $model->delete(); } @@ -134,11 +132,9 @@ public function testCheckClassCanBeDeletedProductClassUsedInTaxRule() /** @var $model \Magento\Tax\Model\ClassModel */ $model = $this->_objectManager->create(\Magento\Tax\Model\ClassModel::class)->load($productClasses[0]); - $this->expectException( - \Magento\Framework\Exception\CouldNotDeleteException::class, - 'You cannot delete this tax class because it is used in' . - ' Tax Rules. You have to delete the rules it is used in first.' - ); + $this->expectException(\Magento\Framework\Exception\CouldNotDeleteException::class); + $this->expectExceptionMessage('You cannot delete this tax class because it is used in' . + ' Tax Rules. You have to delete the rules it is used in first.'); $model->delete(); } } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/RepositoryTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/RepositoryTest.php index 0340ede79edaf..fa20127984d77 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/RepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/RepositoryTest.php @@ -160,10 +160,8 @@ public function testDeleteById() $this->assertTrue($this->taxClassRepository->deleteById($taxClassId)); // Verify if the tax class is deleted - $this->expectException( - \Magento\Framework\Exception\NoSuchEntityException::class, - "No such entity with class_id = $taxClassId" - ); + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $this->expectExceptionMessage("No such entity with class_id = $taxClassId"); $this->taxClassRepository->deleteById($taxClassId); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php index 183f9f2ac567c..a08dcc35f5ba3 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Filesystem/DirectoryListTest.php @@ -23,10 +23,8 @@ public function testDirectoriesCustomization() $this->assertFileExists($object->getPath(DirectoryList::SYS_TMP)); $this->assertEquals('/root/dir/foo', $object->getPath(DirectoryList::APP)); $this->assertEquals('bar', $object->getUrlPath(DirectoryList::APP)); - $this->expectException( - \Magento\Framework\Exception\FileSystemException::class, - "Unknown directory type: 'unknown'" - ); + $this->expectException(\Magento\Framework\Exception\FileSystemException::class); + $this->expectExceptionMessage("Unknown directory type: 'unknown'"); $object->getPath('unknown'); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php index fc139ba2dd9c3..144fd5fbab4b8 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php @@ -185,10 +185,8 @@ public function testSetPublicHeaders() */ public function testSetPublicHeadersWithoutTtl() { - $this->expectException( - 'InvalidArgumentException', - 'Time to live is a mandatory parameter for set public headers' - ); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Time to live is a mandatory parameter for set public headers'); $this->model->setPublicHeaders(null); } @@ -223,10 +221,8 @@ public function testSetPrivateHeaders() */ public function testSetPrivateHeadersWithoutTtl() { - $this->expectException( - 'InvalidArgumentException', - 'Time to live is a mandatory parameter for set private headers' - ); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Time to live is a mandatory parameter for set private headers'); $this->model->setPrivateHeaders(null); } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php index 2385ba83418ca..687632074b35f 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorIntegrityTest.php @@ -43,10 +43,8 @@ public function testValidateIfClassHasExtraArgumentInTheParentConstructor() { $fileName = realpath(__DIR__ . '/../_files/app/code/Magento/SomeModule/Model/Four/Test.php'); $fileName = str_replace('\\', '/', $fileName); - $this->expectException( - \Magento\Framework\Exception\ValidatorException::class, - 'Extra parameters passed to parent construct: $factory. File: ' . $fileName - ); + $this->expectException(\Magento\Framework\Exception\ValidatorException::class); + $this->expectExceptionMessage('Extra parameters passed to parent construct: $factory. File: ' . $fileName); $this->_model->validate(\Magento\SomeModule\Model\Four\Test::class); } @@ -54,8 +52,8 @@ public function testValidateIfClassHasMissingRequiredArguments() { $fileName = realpath(__DIR__ . '/../_files/app/code/Magento/SomeModule/Model/Five/Test.php'); $fileName = str_replace('\\', '/', $fileName); - $this->expectException( - \Magento\Framework\Exception\ValidatorException::class, + $this->expectException(\Magento\Framework\Exception\ValidatorException::class); + $this->expectExceptionMessage( 'Missed required argument factory in parent::__construct call. File: ' . $fileName ); $this->_model->validate(\Magento\SomeModule\Model\Five\Test::class); @@ -65,8 +63,8 @@ public function testValidateIfClassHasIncompatibleArguments() { $fileName = realpath(__DIR__ . '/../_files/app/code/Magento/SomeModule/Model/Six/Test.php'); $fileName = str_replace('\\', '/', $fileName); - $this->expectException( - \Magento\Framework\Exception\ValidatorException::class, + $this->expectException(\Magento\Framework\Exception\ValidatorException::class); + $this->expectExceptionMessage( 'Incompatible argument type: Required type: \Magento\SomeModule\Model\Proxy. ' . 'Actual type: \Magento\SomeModule\Model\ElementFactory; File: ' . PHP_EOL . @@ -79,8 +77,8 @@ public function testValidateWrongOrderForParentArguments() { $fileName = realpath(__DIR__) . '/_files/ClassesForConstructorIntegrity.php'; $fileName = str_replace('\\', '/', $fileName); - $this->expectException( - \Magento\Framework\Exception\ValidatorException::class, + $this->expectException(\Magento\Framework\Exception\ValidatorException::class); + $this->expectExceptionMessage( 'Incompatible argument type: Required type: \Context. ' . 'Actual type: \ClassA; File: ' . PHP_EOL . @@ -93,8 +91,8 @@ public function testValidateWrongOptionalParamsType() { $fileName = realpath(__DIR__) . '/_files/ClassesForConstructorIntegrity.php'; $fileName = str_replace('\\', '/', $fileName); - $this->expectException( - \Magento\Framework\Exception\ValidatorException::class, + $this->expectException(\Magento\Framework\Exception\ValidatorException::class); + $this->expectExceptionMessage( 'Incompatible argument type: Required type: array. ' . 'Actual type: \ClassB; File: ' . PHP_EOL . $fileName ); $this->_model->validate('ClassArgumentWithWrongParentArgumentsType'); diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php index f7c6961c30010..93abeae644f61 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php @@ -109,7 +109,7 @@ public function constructorDataProvider() 'node_data' => true, 'keys' => null, ], \Magento\Framework\Exception\LocalizedException::class, - 'Enter the key and try again.' + 'The encryption key can\'t be empty. Enter the key and try again.' ] ]; } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php index a34fdf21f7ab4..b28b1fa167b60 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php @@ -54,8 +54,8 @@ protected function setUp() public function testGetElementHtmlException() { - $this->expectException( - 'Exception', + $this->expectException('Exception'); + $this->expectExceptionMessage( 'Output format is not specified. Please specify "format" key in constructor, or set it using setFormat().' ); $formMock = $this->getFormMock('never'); diff --git a/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php b/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php index f9e78eb0a36e6..88fe1309871e4 100644 --- a/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php +++ b/lib/internal/Magento/Framework/Message/Test/Unit/FactoryTest.php @@ -38,8 +38,8 @@ public function testCreateWithWrongTypeException() public function testCreateWithWrongInterfaceImplementation() { - $this->expectException( - '\InvalidArgumentException', + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage( 'Magento\Framework\Message\Error doesn\'t implement \Magento\Framework\Message\MessageInterface' ); $messageMock = new \stdClass(); diff --git a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageControllerTest.php b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageControllerTest.php index dc35a6dd26d47..eb1d4c4cafdac 100644 --- a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageControllerTest.php +++ b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageControllerTest.php @@ -50,10 +50,8 @@ public function testLockWithNotFoundException() { $properties = []; $consumerName = ''; - $this->expectException( - \Magento\Framework\Exception\NotFoundException::class, - "Property 'message_id' not found in properties." - ); + $this->expectException(\Magento\Framework\Exception\NotFoundException::class); + $this->expectExceptionMessage("Property 'message_id' not found in properties."); $this->lockFactory->expects($this->once())->method('create'); $envelope = $this->getMockBuilder(\Magento\Framework\MessageQueue\EnvelopeInterface::class) ->disableArgumentCloning()->getMock(); diff --git a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/CompositeValidatorTest.php b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/CompositeValidatorTest.php index f53899f318d09..412a58df86eb7 100644 --- a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/CompositeValidatorTest.php +++ b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/CompositeValidatorTest.php @@ -61,8 +61,8 @@ public function testValidatorThrowsException() public function testInvalidReaderInstance() { - $this->expectException( - '\LogicException', + $this->expectException('\LogicException'); + $this->expectExceptionMessage( 'Validator [stdClass] does not implements ' . 'Magento\Framework\MessageQueue\Publisher\Config\ValidatorInterface' ); diff --git a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/Validator/EnabledConnectionTest.php b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/Validator/EnabledConnectionTest.php index 334bd20de5e58..bd92b1c4d1cec 100644 --- a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/Validator/EnabledConnectionTest.php +++ b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/Publisher/Config/Validator/EnabledConnectionTest.php @@ -49,8 +49,8 @@ public function testValidateValidConfig() public function testValidateMultipleEnabledConnections() { - $this->expectException( - '\LogicException', + $this->expectException('\LogicException'); + $this->expectExceptionMessage( 'More than 1 enabled connections configured for publisher pub01. ' . 'More than 1 enabled connections configured for publisher pub02.' ); diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php index 4f0afa9388216..f0f42c5931ad3 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php @@ -111,10 +111,8 @@ public function testGetVersionWithExceptionNoAutoincrement() ->method('fetchRow') ->will($this->returnValue([])); - $this->expectException( - 'Exception', - "Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id." - ); + $this->expectException('Exception'); + $this->expectExceptionMessage("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id."); $this->model->setViewId('viewIdtest'); $this->model->getVersion(); } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php index 8deb2750653e7..309bf48548ec7 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php @@ -110,8 +110,8 @@ public function testCreateWithInjectable() */ public function testCircular($startingClass, $terminationClass) { - $this->expectException( - '\LogicException', + $this->expectException('\LogicException'); + $this->expectExceptionMessage( sprintf('Circular dependency: %s depends on %s and vice versa.', $startingClass, $terminationClass) ); $this->factory->create($startingClass); diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php index 221f97f72daf4..a2923417d5018 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/FactoryTest.php @@ -83,8 +83,8 @@ public function createDataProvider() public function testCreateUndefinedClass() { - $this->expectException( - 'InvalidArgumentException', + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage( 'Cannot create profiler driver, class "Magento_Framework_Profiler_Driver_Test_Baz" doesn\'t exist.' ); $this->_factory->create(['type' => 'baz']); diff --git a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php index 49468b3c347ac..6fddf6a0ac977 100644 --- a/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php +++ b/lib/internal/Magento/Framework/Profiler/Test/Unit/Driver/Standard/Output/FactoryTest.php @@ -83,8 +83,8 @@ public function createDataProvider() public function testCreateUndefinedClass() { - $this->expectException( - 'InvalidArgumentException', + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage( sprintf( 'Cannot create standard driver output, class "%s" doesn\'t exist.', 'Magento_Framework_Profiler_Driver_Standard_Output_Test_Baz' @@ -95,8 +95,8 @@ public function testCreateUndefinedClass() public function testCreateInvalidClass() { - $this->expectException( - 'InvalidArgumentException', + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage( 'Output class "stdClass" must implement \Magento\Framework\Profiler\Driver\Standard\OutputInterface.' ); $this->_factory->create(['type' => 'stdClass']); diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php index 4b5cd49dc2fe4..4543b3b6eec12 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php @@ -212,11 +212,9 @@ public function testProcessSimpleTypeStringArrayToIntArray() */ public function testProcessSimpleTypeException($value, $type) { - $this->expectException( - SerializationException::class, - 'The "' - . $value . '" value\'s type is invalid. The "' . $type . '" type was expected. Verify and try again.' - ); + $this->expectException(SerializationException::class); + $this->expectExceptionMessage('The "' + . $value . '" value\'s type is invalid. The "' . $type . '" type was expected. Verify and try again.'); $this->_typeProcessor->processSimpleAndAnyType($value, $type); } diff --git a/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php index 12e28cdb3970d..19c21ff3529ce 100644 --- a/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Session/Test/Unit/ConfigTest.php @@ -177,10 +177,8 @@ public function testSettingInvalidCookieLifetime2() public function testWrongMethodCall() { $this->getModel($this->validatorMock); - $this->expectException( - '\BadMethodCallException', - 'Method "methodThatNotExist" does not exist in Magento\Framework\Session\Config' - ); + $this->expectException('\BadMethodCallException'); + $this->expectExceptionMessage('Method "methodThatNotExist" does not exist in Magento\Framework\Session\Config'); $this->config->methodThatNotExist(); } diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php index 860d449c4717e..cc5e3e60032fd 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php @@ -413,10 +413,9 @@ public function invalidArgumentsDataProvider() */ public function testCreateValidatorInvalidInstance() { - $this->expectException( - 'InvalidArgumentException', - 'Constraint class "StdClass" must implement \Magento\Framework\Validator\ValidatorInterface' - ); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Constraint class "StdClass" must implement \Magento\Framework\Validator\ValidatorInterface'); + $builder = $this->_objectManager->getObject( \Magento\Framework\Validator\Builder::class, [ diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php index bf660396790f7..77540035fd26d 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php @@ -117,10 +117,8 @@ public function testCreateValidatorInvalidGroupName() public function testCreateValidatorInvalidConstraintClass() { - $this->expectException( - 'InvalidArgumentException', - 'Constraint class "stdClass" must implement \Magento\Framework\Validator\ValidatorInterface' - ); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Constraint class "stdClass" must implement \Magento\Framework\Validator\ValidatorInterface'); $this->_initConfig([__DIR__ . '/_files/validation/negative/invalid_constraint.xml']); $this->_config->createValidator('test_entity', 'test_group'); } diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php index 9d4153ee3006f..75d58158c4560 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/Option/CallbackTest.php @@ -32,7 +32,7 @@ class CallbackTest extends \PHPUnit\Framework\TestCase public function testGetValue($callback, $expectedResult, $arguments = null, $createInstance = false) { $option = new Callback($callback, $arguments, $createInstance); - self::assertEquals($expectedResult, $option->getValue()); + $this->assertEquals($expectedResult, $option->getValue()); } /** @@ -106,7 +106,7 @@ public function testSetArguments($value, $expectedValue) $option = new Callback(function () { }); $option->setArguments($value); - self::assertAttributeEquals($expectedValue, '_arguments', $option); + $this->assertAttributeEquals($expectedValue, '_arguments', $option); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php index 6b4994e9e8d8c..a1a52ac261ccf 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/Resolver/AlternativeTest.php @@ -49,7 +49,8 @@ protected function setUp() */ public function testConstructorException(array $alternativeExtensions) { - $this->expectException('\InvalidArgumentException', "\$alternativeExtensions must be an array with format:" + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage("\$alternativeExtensions must be an array with format:" . " array('ext1' => array('ext1', 'ext2'), 'ext3' => array(...)]"); $readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php index d6555a2264731..bc8a192d14523 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/Domain/FactoryTest.php @@ -56,10 +56,8 @@ public function testCreateWithWrongThemeType() $themeDomainFactory = new \Magento\Framework\View\Design\Theme\Domain\Factory($objectManager); - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - sprintf('Invalid type of theme domain model "%s"', $wrongThemeType) - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage(sprintf('Invalid type of theme domain model "%s"', $wrongThemeType)); $themeDomainFactory->create($themeMock); } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php index afa0db13e97c3..8d4e852cf658a 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Message/Renderer/BlockRendererTest.php @@ -87,10 +87,8 @@ public function testRenderNoTemplate() ->method('getData') ->willReturn($messageData); - $this->expectException( - 'InvalidArgumentException', - 'Template should be provided for the renderer.' - ); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage('Template should be provided for the renderer.'); $this->blockTemplate->expects(static::never()) ->method('toHtml'); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php index 795e985512022..064485a06c521 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/FactoryTest.php @@ -26,10 +26,8 @@ public function testCreateInvalidArgument() $factory = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) ->getObject(\Magento\Framework\View\Layout\ReaderFactory::class, ['objectManager' => $objectManager]); - $this->expectException( - '\InvalidArgumentException', - $className . ' doesn\'t implement \Magento\Framework\View\Layout\ReaderInterface' - ); + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage($className . ' doesn\'t implement \Magento\Framework\View\Layout\ReaderInterface'); $factory->create($className, $data); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php index 400e9cf3d1ed7..d979f66e5adf1 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/ConfigTest.php @@ -412,10 +412,8 @@ public function elementAttributeDataProvider() */ public function testElementAttributeException($elementType, $attribute, $value) { - $this->expectException( - \Magento\Framework\Exception\LocalizedException::class, - $elementType . " isn't allowed" - ); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectExceptionMessage($elementType . " isn't allowed"); $this->model->setElementAttribute($elementType, $attribute, $value); } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php index 588a67430a61f..0c58e2c251ccd 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/DeserializerFactoryTest.php @@ -40,10 +40,8 @@ public function testGet() public function testGetMagentoWebapiException() { $expectedMetadata = ['text_xml' => ['type' => 'text/xml', 'model' => 'Xml']]; - $this->expectException( - \Magento\Framework\Webapi\Exception::class, - 'Server cannot understand Content-Type HTTP header media type text_xml' - ); + $this->expectException(\Magento\Framework\Webapi\Exception::class); + $this->expectExceptionMessage('Server cannot understand Content-Type HTTP header media type text_xml'); $interpreterFactory = new \Magento\Framework\Webapi\Rest\Request\DeserializerFactory( $this->createMock(\Magento\Framework\ObjectManagerInterface::class), $expectedMetadata @@ -58,8 +56,8 @@ public function testGetLogicExceptionInvalidRequestDeserializer() \Magento\Framework\Webapi\Response\Rest\Renderer\Json::class )->disableOriginalConstructor()->getMock(); - $this->expectException( - 'LogicException', + $this->expectException('LogicException'); + $this->expectExceptionMessage( 'The deserializer must implement "Magento\Framework\Webapi\Rest\Request\DeserializerInterface".' ); $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php index ba460c5a5f6e6..d1c99cc776f40 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Response/RendererFactoryTest.php @@ -108,10 +108,8 @@ public function testGetWithWrongRendererClass() $this->returnValue(new \Magento\Framework\DataObject()) ); - $this->expectException( - 'LogicException', - 'The renderer must implement "Magento\Framework\Webapi\Rest\Response\RendererInterface".' - ); + $this->expectException('LogicException'); + $this->expectExceptionMessage('The renderer must implement "Magento\Framework\Webapi\Rest\Response\RendererInterface".'); $this->_factory->get(); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php b/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php index 49c39c87b9d21..ab361e46c4a7e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/BasePackageInfoTest.php @@ -48,8 +48,8 @@ public function testBaseComposerJsonFileNotFound() $this->readerMock->expects($this->once())->method('isExist')->willReturn(false); $this->readerMock->expects($this->never())->method('isReadable'); $this->readerMock->expects($this->never())->method('readFile'); - $this->expectException( - \Magento\Setup\Exception::class, + $this->expectException(\Magento\Setup\Exception::class); + $this->expectExceptionMessage( sprintf('Could not locate %s file.', BasePackageInfo::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE) ); $this->basePackageInfo->getPaths(); @@ -61,8 +61,8 @@ public function testBaseComposerJsonFileNotReadable() $this->readerMock->expects($this->once())->method('isExist')->willReturn(true); $this->readerMock->expects($this->once())->method('isReadable')->willReturn(false); $this->readerMock->expects($this->never())->method('readFile'); - $this->expectException( - \Magento\Setup\Exception::class, + $this->expectException(\Magento\Setup\Exception::class); + $this->expectExceptionMessage( sprintf('Could not read %s file.', BasePackageInfo::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE) ); $this->basePackageInfo->getPaths(); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php index d15bd2fd80c67..515badda91720 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/OperationFactoryTest.php @@ -54,8 +54,8 @@ public function testCreateSuccess($alias, $arguments, $instanceName) public function testCreateException() { $notRegisteredOperation = 'coffee'; - $this->expectException( - \Magento\Setup\Module\Di\App\Task\OperationException::class, + $this->expectException(\Magento\Setup\Module\Di\App\Task\OperationException::class); + $this->expectExceptionMessage( sprintf('Unrecognized operation "%s"', $notRegisteredOperation), OperationException::UNAVAILABLE_OPERATION );