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 31a13191750a3..2f0102ffd410d 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
@@ -20,7 +20,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/Catalog/Model/Product/Gallery/Processor.php b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php
index 31e322f4e38f2..ac2a01f9c5a84 100644
--- a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php
+++ b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php
@@ -149,7 +149,7 @@ public function addImage(
}
$fileName = \Magento\MediaStorage\Model\File\Uploader::getCorrectFileName($pathinfo['basename']);
- $dispretionPath = \Magento\MediaStorage\Model\File\Uploader::getDispretionPath($fileName);
+ $dispretionPath = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName);
$fileName = $dispretionPath . '/' . $fileName;
$fileName = $this->getNotDuplicatedFilename($fileName, $dispretionPath);
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php
index af6c4dba784f0..b54c66d75a058 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php
@@ -150,7 +150,7 @@ public function validate($processingParams, $option)
$extension = pathinfo(strtolower($fileInfo['name']), PATHINFO_EXTENSION);
$fileName = \Magento\MediaStorage\Model\File\Uploader::getCorrectFileName($fileInfo['name']);
- $dispersion = \Magento\MediaStorage\Model\File\Uploader::getDispretionPath($fileName);
+ $dispersion = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName);
$filePath = $dispersion;
diff --git a/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php b/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php
new file mode 100644
index 0000000000000..342b703ded0a5
--- /dev/null
+++ b/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php
@@ -0,0 +1,58 @@
+collectionFactory = $collectionFactory;
+ }
+
+ /**
+ * Delete related to specific attribute set products, if attribute set was removed successfully.
+ *
+ * @param AttributeSetRepositoryInterface $subject
+ * @param bool $result
+ * @param AttributeSetInterface $attributeSet
+ * @return bool
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterDelete(
+ AttributeSetRepositoryInterface $subject,
+ bool $result,
+ AttributeSetInterface $attributeSet
+ ) {
+ /** @var Collection $productCollection */
+ $productCollection = $this->collectionFactory->create();
+ $productCollection->addFieldToFilter('attribute_set_id', ['eq' => $attributeSet->getId()]);
+ $productCollection->delete();
+
+ return $result;
+ }
+}
diff --git a/app/code/Magento/Catalog/Setup/UpgradeSchema.php b/app/code/Magento/Catalog/Setup/UpgradeSchema.php
index 616bee43de00e..d08108d1fc22b 100755
--- a/app/code/Magento/Catalog/Setup/UpgradeSchema.php
+++ b/app/code/Magento/Catalog/Setup/UpgradeSchema.php
@@ -21,6 +21,8 @@ class UpgradeSchema implements UpgradeSchemaInterface
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
@@ -126,6 +128,10 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
$this->fixCustomerGroupIdColumn($setup);
}
+ if (version_compare($context->getVersion(), '2.2.4', '<')) {
+ $this->removeAttributeSetRelation($setup);
+ }
+
$setup->endSetup();
}
@@ -699,4 +705,20 @@ private function addReplicaTable(SchemaSetupInterface $setup, $existingTable, $r
);
$setup->getConnection()->query($sql);
}
+
+ /**
+ * Remove foreign key between catalog_product_entity and eav_attribute_set tables.
+ * Drop foreign key to delegate cascade on delete to plugin.
+ * @see \Magento\Catalog\Plugin\Model\AttributeSetRepository\RemoveProducts
+ *
+ * @param SchemaSetupInterface $setup
+ * @return void
+ */
+ private function removeAttributeSetRelation(SchemaSetupInterface $setup)
+ {
+ $setup->getConnection()->dropForeignKey(
+ $setup->getTable('catalog_product_entity'),
+ $setup->getFkName('catalog_product_entity', 'attribute_set_id', 'eav_attribute_set', 'attribute_set_id')
+ );
+ }
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php
index 1bc5e450ae153..f77a6fec283a5 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
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/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
new file mode 100644
index 0000000000000..712aeba59dffe
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
@@ -0,0 +1,87 @@
+collectionFactory = $this->getMockBuilder(CollectionFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->testSubject = $objectManager->getObject(
+ RemoveProducts::class,
+ [
+ 'collectionFactory' => $this->collectionFactory,
+ ]
+ );
+ }
+
+ /**
+ * Test plugin will delete all related products for given attribute set.
+ */
+ public function testAfterDelete()
+ {
+ $attributeSetId = '1';
+
+ /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collection */
+ $collection = $this->getMockBuilder(Collection::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $collection->expects(self::once())
+ ->method('addFieldToFilter')
+ ->with(self::identicalTo('attribute_set_id'), self::identicalTo(['eq' => $attributeSetId]));
+ $collection->expects(self::once())
+ ->method('delete');
+
+ $this->collectionFactory->expects(self::once())
+ ->method('create')
+ ->willReturn($collection);
+
+ /** @var AttributeSetRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject $attributeSetRepository */
+ $attributeSetRepository = $this->getMockBuilder(AttributeSetRepositoryInterface::class)
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ /** @var AttributeSetInterface|\PHPUnit_Framework_MockObject_MockObject $attributeSet */
+ $attributeSet = $this->getMockBuilder(AttributeSetInterface::class)
+ ->setMethods(['getId'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+ $attributeSet->expects(self::once())
+ ->method('getId')
+ ->willReturn($attributeSetId);
+
+ self::assertTrue($this->testSubject->afterDelete($attributeSetRepository, true, $attributeSet));
+ }
+}
diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml
index b97e6fc1aa318..34d089580906f 100644
--- a/app/code/Magento/Catalog/etc/adminhtml/di.xml
+++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml
@@ -184,4 +184,7 @@
Magento\Catalog\Model\Attribute\ScopeOverriddenValue
+
+
+
diff --git a/app/code/Magento/Catalog/etc/module.xml b/app/code/Magento/Catalog/etc/module.xml
index 18671a32bb4fb..26ed173420adb 100644
--- a/app/code/Magento/Catalog/etc/module.xml
+++ b/app/code/Magento/Catalog/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
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/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/Console/Command/ConfigSet/ProcessorFacadeTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php
index 4e65ab3f4cc21..0f5852c322bdd 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php
@@ -132,7 +132,8 @@ public function testProcess()
*/
public function testProcessWithValidatorException(LocalizedException $exception)
{
- $this->expectException(ValidatorException::class, 'Some error');
+ $this->expectException(ValidatorException::class);
+ $this->expectExceptionMessage('Some error');
$this->scopeValidatorMock->expects($this->once())
->method('isValid')
->willThrowException($exception);
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 2d824e52c7244..ab3fd33322aa5 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php
@@ -356,7 +356,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/Model/FileProcessor.php b/app/code/Magento/Customer/Model/FileProcessor.php
index 2d6917efdaf56..6a8472758c169 100644
--- a/app/code/Magento/Customer/Model/FileProcessor.php
+++ b/app/code/Magento/Customer/Model/FileProcessor.php
@@ -202,7 +202,7 @@ public function moveTemporaryFile($fileName)
{
$fileName = ltrim($fileName, '/');
- $dispersionPath = \Magento\MediaStorage\Model\File\Uploader::getDispretionPath($fileName);
+ $dispersionPath = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName);
$destinationPath = $this->entityTypeCode . $dispersionPath;
if (!$this->mediaDirectory->create($destinationPath)) {
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 78465e57c6236..e976d031e965f 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/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/Indexer/Console/Command/IndexerStatusCommand.php b/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php
index 6590f6e0af99d..22acdc6f82bbc 100644
--- a/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php
+++ b/app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php
@@ -7,6 +7,8 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Magento\Framework\Indexer;
+use Magento\Framework\Mview;
/**
* Command for displaying status of indexers.
@@ -30,21 +32,84 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $table = $this->getHelperSet()->get('table');
+ $table->setHeaders(['Title', 'Status', 'Update On', 'Schedule Status', 'Schedule Updated']);
+
+ $rows = [];
+
$indexers = $this->getIndexers($input);
foreach ($indexers as $indexer) {
- $status = 'unknown';
- switch ($indexer->getStatus()) {
- case \Magento\Framework\Indexer\StateInterface::STATUS_VALID:
- $status = 'Ready';
- break;
- case \Magento\Framework\Indexer\StateInterface::STATUS_INVALID:
- $status = 'Reindex required';
- break;
- case \Magento\Framework\Indexer\StateInterface::STATUS_WORKING:
- $status = 'Processing';
- break;
+ $view = $indexer->getView();
+
+ $rowData = [
+ 'Title' => $indexer->getTitle(),
+ 'Status' => $this->getStatus($indexer),
+ 'Update On' => $indexer->isScheduled() ? 'Schedule' : 'Save',
+ 'Schedule Status' => '',
+ 'Updated' => '',
+ ];
+
+ if ($indexer->isScheduled()) {
+ $state = $view->getState();
+ $rowData['Schedule Status'] = "{$state->getStatus()} ({$this->getPendingCount($view)} in backlog)";
+ $rowData['Updated'] = $state->getUpdated();
}
- $output->writeln(sprintf('%-50s ', $indexer->getTitle() . ':') . $status);
+
+ $rows[] = $rowData;
+ }
+
+ usort($rows, function ($comp1, $comp2) {
+ return strcmp($comp1['Title'], $comp2['Title']);
+ });
+
+ $table->addRows($rows);
+ $table->render($output);
+ }
+
+ /**
+ * @param Indexer\IndexerInterface $indexer
+ * @return string
+ */
+ private function getStatus(Indexer\IndexerInterface $indexer)
+ {
+ $status = 'unknown';
+ switch ($indexer->getStatus()) {
+ case \Magento\Framework\Indexer\StateInterface::STATUS_VALID:
+ $status = 'Ready';
+ break;
+ case \Magento\Framework\Indexer\StateInterface::STATUS_INVALID:
+ $status = 'Reindex required';
+ break;
+ case \Magento\Framework\Indexer\StateInterface::STATUS_WORKING:
+ $status = 'Processing';
+ break;
}
+ return $status;
+ }
+
+ /**
+ * @param Mview\ViewInterface $view
+ * @return string
+ */
+ private function getPendingCount(Mview\ViewInterface $view)
+ {
+ $changelog = $view->getChangelog();
+
+ try {
+ $currentVersionId = $changelog->getVersion();
+ } catch (Mview\View\ChangelogTableNotExistsException $e) {
+ return '';
+ }
+
+ $state = $view->getState();
+
+ $pendingCount = count($changelog->getList($state->getVersionId(), $currentVersionId));
+
+ $pendingString = "$pendingCount";
+ if ($pendingCount <= 0) {
+ $pendingString = "$pendingCount";
+ }
+
+ return $pendingString;
}
}
diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php
index 6eb7f7562b9cc..31513da018c6b 100644
--- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php
+++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php
@@ -8,6 +8,8 @@
use Magento\Framework\Indexer\StateInterface;
use Magento\Indexer\Console\Command\IndexerStatusCommand;
use Symfony\Component\Console\Tester\CommandTester;
+use Symfony\Component\Console\Helper\HelperSet;
+use Symfony\Component\Console\Helper\TableHelper;
class IndexerStatusCommandTest extends AbstractIndexerCommandCommonSetup
{
@@ -18,35 +20,134 @@ class IndexerStatusCommandTest extends AbstractIndexerCommandCommonSetup
*/
private $command;
+ /**
+ * @param \PHPUnit_Framework_MockObject_MockObject $indexerMock
+ * @param array $data
+ * @return mixed
+ */
+ private function attachViewToIndexerMock($indexerMock, array $data)
+ {
+ /** @var \Magento\Framework\Mview\View\Changelog|\PHPUnit_Framework_MockObject_MockObject $changelog */
+ $changelog = $this->getMockBuilder(\Magento\Framework\Mview\View\Changelog::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $changelog->expects($this->any())
+ ->method('getList')
+ ->willReturn(range(0, $data['view']['changelog']['list_size']-1));
+
+ /** @var \Magento\Indexer\Model\Mview\View\State|\PHPUnit_Framework_MockObject_MockObject $stateMock */
+ $stateMock = $this->getMockBuilder(\Magento\Indexer\Model\Mview\View\State::class)
+ ->disableOriginalConstructor()
+ ->setMethods(null)
+ ->getMock();
+
+ $stateMock->addData($data['view']['state']);
+
+ /** @var \Magento\Framework\Mview\View|\PHPUnit_Framework_MockObject_MockObject $viewMock */
+ $viewMock = $this->getMockBuilder(\Magento\Framework\Mview\View::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getChangelog', 'getState'])
+ ->getMock();
+
+ $viewMock->expects($this->any())
+ ->method('getState')
+ ->willReturn($stateMock);
+ $viewMock->expects($this->any())
+ ->method('getChangelog')
+ ->willReturn($changelog);
+
+ $indexerMock->method('getView')
+ ->willReturn($viewMock);
+
+ return $indexerMock;
+ }
+
/**
* @param array $indexers
- * @param array $statuses
+ *
* @dataProvider executeAllDataProvider
*/
- public function testExecuteAll(array $indexers, array $statuses)
+ public function testExecuteAll(array $indexers)
{
$this->configureAdminArea();
$indexerMocks = [];
foreach ($indexers as $indexerData) {
$indexerMock = $this->getIndexerMock(
- ['getStatus'],
+ ['getStatus', 'isScheduled', 'getState', 'getView'],
$indexerData
);
+
$indexerMock->method('getStatus')
- ->willReturn($statuses[$indexerData['indexer_id']]);
+ ->willReturn($indexerData['status']);
+ $indexerMock->method('isScheduled')
+ ->willReturn($indexerData['is_scheduled']);
+
+ if ($indexerData['is_scheduled']) {
+ $this->attachViewToIndexerMock($indexerMock, $indexerData);
+ }
+
$indexerMocks[] = $indexerMock;
}
+
$this->initIndexerCollectionByItems($indexerMocks);
$this->command = new IndexerStatusCommand($this->objectManagerFactory);
+
+ $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+
+ $this->command->setHelperSet(
+ $objectManager->getObject(
+ HelperSet::class,
+ ['helpers' => [$objectManager->getObject(TableHelper::class)]]
+ )
+ );
+
$commandTester = new CommandTester($this->command);
$commandTester->execute([]);
- $actualValue = $commandTester->getDisplay();
- $expectedValue = sprintf('%-50s ', 'Title_indexerOne' . ':') . 'Ready' . PHP_EOL
- . sprintf('%-50s ', 'Title_indexerTwo' . ':') . 'Reindex required' . PHP_EOL
- . sprintf('%-50s ', 'Title_indexerThree' . ':') . 'Processing' . PHP_EOL
- . sprintf('%-50s ', 'Title_indexerFour' . ':') . 'unknown' . PHP_EOL;
- $this->assertStringStartsWith($expectedValue, $actualValue);
+ $linesOutput = array_filter(explode(PHP_EOL, $commandTester->getDisplay()));
+
+ $spacer = '+----------------+------------------+-----------+-------------------------+---------------------+';
+
+ $this->assertCount(8, $linesOutput, 'There should be 8 lines output. 3 Spacers, 1 header, 4 content.');
+ $this->assertEquals($linesOutput[0], $spacer, "Lines 0, 2, 7 should be spacer lines");
+ $this->assertEquals($linesOutput[2], $spacer, "Lines 0, 2, 7 should be spacer lines");
+ $this->assertEquals($linesOutput[7], $spacer, "Lines 0, 2, 7 should be spacer lines");
+
+ $headerValues = array_values(array_filter(explode('|', $linesOutput[1])));
+ $this->assertEquals('Title', trim($headerValues[0]));
+ $this->assertEquals('Status', trim($headerValues[1]));
+ $this->assertEquals('Update On', trim($headerValues[2]));
+ $this->assertEquals('Schedule Status', trim($headerValues[3]));
+ $this->assertEquals('Schedule Updated', trim($headerValues[4]));
+
+ $indexer1 = array_values(array_filter(explode('|', $linesOutput[3])));
+ $this->assertEquals('Title_indexer1', trim($indexer1[0]));
+ $this->assertEquals('Ready', trim($indexer1[1]));
+ $this->assertEquals('Schedule', trim($indexer1[2]));
+ $this->assertEquals('idle (10 in backlog)', trim($indexer1[3]));
+ $this->assertEquals('2017-01-01 11:11:11', trim($indexer1[4]));
+
+ $indexer2 = array_values(array_filter(explode('|', $linesOutput[4])));
+ $this->assertEquals('Title_indexer2', trim($indexer2[0]));
+ $this->assertEquals('Reindex required', trim($indexer2[1]));
+ $this->assertEquals('Save', trim($indexer2[2]));
+ $this->assertEquals('', trim($indexer2[3]));
+ $this->assertEquals('', trim($indexer2[4]));
+
+ $indexer3 = array_values(array_filter(explode('|', $linesOutput[5])));
+ $this->assertEquals('Title_indexer3', trim($indexer3[0]));
+ $this->assertEquals('Processing', trim($indexer3[1]));
+ $this->assertEquals('Schedule', trim($indexer3[2]));
+ $this->assertEquals('idle (100 in backlog)', trim($indexer3[3]));
+ $this->assertEquals('2017-01-01 11:11:11', trim($indexer3[4]));
+
+ $indexer4 = array_values(array_filter(explode('|', $linesOutput[6])));
+ $this->assertEquals('Title_indexer4', trim($indexer4[0]));
+ $this->assertEquals('unknown', trim($indexer4[1]));
+ $this->assertEquals('Schedule', trim($indexer4[2]));
+ $this->assertEquals('running (20 in backlog)', trim($indexer4[3]));
+ $this->assertEquals('2017-01-01 11:11:11', trim($indexer4[4]));
}
/**
@@ -59,27 +160,65 @@ public function executeAllDataProvider()
'indexers' => [
'indexer_1' => [
'indexer_id' => 'indexer_1',
- 'title' => 'Title_indexerOne'
+ 'title' => 'Title_indexer1',
+ 'status' => StateInterface::STATUS_VALID,
+ 'is_scheduled' => true,
+ 'view' => [
+ 'state' => [
+ 'status' => 'idle',
+ 'updated' => '2017-01-01 11:11:11',
+ ],
+ 'changelog' => [
+ 'list_size' => 10
+ ]
+ ]
],
'indexer_2' => [
'indexer_id' => 'indexer_2',
- 'title' => 'Title_indexerTwo'
+ 'title' => 'Title_indexer2',
+ 'status' => StateInterface::STATUS_INVALID,
+ 'is_scheduled' => false,
+ 'view' => [
+ 'state' => [
+ 'status' => 'idle',
+ 'updated' => '2017-01-01 11:11:11',
+ ],
+ 'changelog' => [
+ 'list_size' => 99999999
+ ]
+ ]
],
'indexer_3' => [
'indexer_id' => 'indexer_3',
- 'title' => 'Title_indexerThree'
+ 'title' => 'Title_indexer3',
+ 'status' => StateInterface::STATUS_WORKING,
+ 'is_scheduled' => true,
+ 'view' => [
+ 'state' => [
+ 'status' => 'idle',
+ 'updated' => '2017-01-01 11:11:11',
+ ],
+ 'changelog' => [
+ 'list_size' => 100
+ ]
+ ]
],
'indexer_4' => [
'indexer_id' => 'indexer_4',
- 'title' => 'Title_indexerFour'
+ 'title' => 'Title_indexer4',
+ 'status' => null,
+ 'is_scheduled' => true,
+ 'view' => [
+ 'state' => [
+ 'status' => 'running',
+ 'updated' => '2017-01-01 11:11:11',
+ ],
+ 'changelog' => [
+ 'list_size' => 20
+ ]
+ ]
],
],
- 'Statuses' => [
- 'indexer_1' => StateInterface::STATUS_VALID,
- 'indexer_2' => StateInterface::STATUS_INVALID,
- 'indexer_3' => StateInterface::STATUS_WORKING,
- 'indexer_4' => null,
- ]
],
];
}
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/Paypal/Test/Unit/Model/Api/NvpTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php
index 8b270fe24ab15..c0b2bb4fc1dca 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php
@@ -126,7 +126,8 @@ 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, $exceptionCode);
}
$this->curl->expects($this->once())
->method('read')
diff --git a/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php b/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php
index 3658e36a82ec3..9950526182e3e 100644
--- a/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php
+++ b/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php
@@ -110,7 +110,7 @@ public function execute()
$remoteFileUrl = $this->getRequest()->getParam('remote_image');
$this->validateRemoteFile($remoteFileUrl);
$localFileName = Uploader::getCorrectFileName(basename($remoteFileUrl));
- $localTmpFileName = Uploader::getDispretionPath($localFileName) . DIRECTORY_SEPARATOR . $localFileName;
+ $localTmpFileName = Uploader::getDispersionPath($localFileName) . DIRECTORY_SEPARATOR . $localFileName;
$localFilePath = $baseTmpMediaPath . ($localTmpFileName);
$localUniqFilePath = $this->appendNewFileName($localFilePath);
$this->validateRemoteFileExtensions($localUniqFilePath);
@@ -174,7 +174,7 @@ private function validateRemoteFileExtensions($filePath)
protected function appendResultSaveRemoteImage($fileName)
{
$fileInfo = pathinfo($fileName);
- $tmpFileName = Uploader::getDispretionPath($fileInfo['basename']) . DIRECTORY_SEPARATOR . $fileInfo['basename'];
+ $tmpFileName = Uploader::getDispersionPath($fileInfo['basename']) . DIRECTORY_SEPARATOR . $fileInfo['basename'];
$result['name'] = $fileInfo['basename'];
$result['type'] = $this->imageAdapter->getMimeType();
$result['error'] = 0;
diff --git a/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js b/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js
index 1dfcc95a552c6..c0036b71ac86a 100644
--- a/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js
+++ b/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js
@@ -175,10 +175,10 @@ define([
*/
clearEvents: function () {
this.fotoramaItem.off(
- 'fotorama:show ' +
- 'fotorama:showend ' +
- 'fotorama:fullscreenenter ' +
- 'fotorama:fullscreenexit'
+ 'fotorama:show.' + this.PV +
+ ' fotorama:showend.' + this.PV +
+ ' fotorama:fullscreenenter.' + this.PV +
+ ' fotorama:fullscreenexit.' + this.PV
);
},
@@ -232,11 +232,11 @@ define([
* @private
*/
_listenForFullscreen: function () {
- this.fotoramaItem.on('fotorama:fullscreenenter', $.proxy(function () {
+ this.fotoramaItem.on('fotorama:fullscreenenter.' + this.PV, $.proxy(function () {
this.isFullscreen = true;
}, this));
- this.fotoramaItem.on('fotorama:fullscreenexit', $.proxy(function () {
+ this.fotoramaItem.on('fotorama:fullscreenexit.' + this.PV, $.proxy(function () {
this.isFullscreen = false;
this._hideVideoArrows();
}, this));
@@ -468,7 +468,7 @@ define([
t;
if (!fotorama.activeFrame.$navThumbFrame) {
- this.fotoramaItem.on('fotorama:showend', $.proxy(function (evt, fotoramaData) {
+ this.fotoramaItem.on('fotorama:showend.' + this.PV, $.proxy(function (evt, fotoramaData) {
$(fotoramaData.activeFrame.$stageFrame).removeAttr('href');
}, this));
@@ -486,7 +486,7 @@ define([
this._checkForVideo(e, fotorama, t + 1);
}
- this.fotoramaItem.on('fotorama:showend', $.proxy(function (evt, fotoramaData) {
+ this.fotoramaItem.on('fotorama:showend.' + this.PV, $.proxy(function (evt, fotoramaData) {
$(fotoramaData.activeFrame.$stageFrame).removeAttr('href');
}, this));
},
@@ -528,15 +528,15 @@ define([
* @private
*/
_attachFotoramaEvents: function () {
- this.fotoramaItem.on('fotorama:showend', $.proxy(function (e, fotorama) {
+ this.fotoramaItem.on('fotorama:showend.' + this.PV, $.proxy(function (e, fotorama) {
this._startPrepareForPlayer(e, fotorama);
}, this));
- this.fotoramaItem.on('fotorama:show', $.proxy(function (e, fotorama) {
+ this.fotoramaItem.on('fotorama:show.' + this.PV, $.proxy(function (e, fotorama) {
this._unloadVideoPlayer(fotorama.activeFrame.$stageFrame.parent(), fotorama, true);
}, this));
- this.fotoramaItem.on('fotorama:fullscreenexit', $.proxy(function (e, fotorama) {
+ this.fotoramaItem.on('fotorama:fullscreenexit.' + this.PV, $.proxy(function (e, fotorama) {
fotorama.activeFrame.$stageFrame.find('.' + this.PV).remove();
this._startPrepareForPlayer(e, fotorama);
}, this));
diff --git a/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php
index f3f14ef8c3543..d219aefe81d45 100644
--- a/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php
+++ b/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php
@@ -220,8 +220,10 @@ protected function _afterLoad()
$orderData = $this->getOrdersData($productIds);
foreach ($items as $item) {
$item->setId($item->getProductId());
- $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate());
- $item->setName($productData[$item->getProductId()]['name']);
+ if (isset($productData[$item->getProductId()])) {
+ $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate());
+ $item->setName($productData[$item->getProductId()]['name']);
+ }
$item->setOrders(0);
if (isset($orderData[$item->getProductId()])) {
$item->setOrders($orderData[$item->getProductId()]['orders']);
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/Model/Config.php b/app/code/Magento/Security/Model/Config.php
index 100f4630a45a6..2135b81eb82b5 100644
--- a/app/code/Magento/Security/Model/Config.php
+++ b/app/code/Magento/Security/Model/Config.php
@@ -24,10 +24,17 @@ class Config implements ConfigInterface
*/
const XML_PATH_ADMIN_AREA = 'admin/security/';
+ /**
+ * Configuration path to frontend area
+ */
+ const XML_PATH_FRONTEND_AREA = 'customer/password/';
+
/**
* Configuration path to fronted area
+ * @deprecated
+ * @see \Magento\Security\Model\Config::XML_PATH_FRONTEND_AREA
*/
- const XML_PATH_FRONTED_AREA = 'customer/password/';
+ const XML_PATH_FRONTED_AREA = self::XML_PATH_FRONTEND_AREA;
/**
* Configuration path to admin account sharing
@@ -134,7 +141,7 @@ protected function getXmlPathPrefix()
if ($this->scope->getCurrentScope() == \Magento\Framework\App\Area::AREA_ADMINHTML) {
return self::XML_PATH_ADMIN_AREA;
}
- return self::XML_PATH_FRONTED_AREA;
+ return self::XML_PATH_FRONTEND_AREA;
}
/**
diff --git a/app/code/Magento/Security/Model/Plugin/AccountManagement.php b/app/code/Magento/Security/Model/Plugin/AccountManagement.php
index dea54b194880d..9476bf46df338 100644
--- a/app/code/Magento/Security/Model/Plugin/AccountManagement.php
+++ b/app/code/Magento/Security/Model/Plugin/AccountManagement.php
@@ -5,10 +5,12 @@
*/
namespace Magento\Security\Model\Plugin;
-use Magento\Security\Model\SecurityManager;
use Magento\Customer\Model\AccountManagement as AccountManagementOriginal;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Exception\SecurityViolationException;
use Magento\Security\Model\PasswordResetRequestEvent;
+use Magento\Security\Model\SecurityManager;
/**
* Magento\Customer\Model\AccountManagement decorator
@@ -30,21 +32,29 @@ class AccountManagement
*/
protected $passwordRequestEvent;
+ /**
+ * @var ScopeInterface
+ */
+ private $scope;
+
/**
* AccountManagement constructor.
*
* @param \Magento\Framework\App\RequestInterface $request
* @param SecurityManager $securityManager
* @param int $passwordRequestEvent
+ * @param ScopeInterface $scope
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Security\Model\SecurityManager $securityManager,
- $passwordRequestEvent = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
+ $passwordRequestEvent = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST,
+ ScopeInterface $scope = null
) {
$this->request = $request;
$this->securityManager = $securityManager;
$this->passwordRequestEvent = $passwordRequestEvent;
+ $this->scope = $scope ?: ObjectManager::getInstance()->get(ScopeInterface::class);
}
/**
@@ -63,10 +73,14 @@ public function beforeInitiatePasswordReset(
$template,
$websiteId = null
) {
- $this->securityManager->performSecurityCheck(
- $this->passwordRequestEvent,
- $email
- );
+ if ($this->scope->getCurrentScope() == \Magento\Framework\App\Area::AREA_FRONTEND
+ || $this->passwordRequestEvent == PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST) {
+ $this->securityManager->performSecurityCheck(
+ $this->passwordRequestEvent,
+ $email
+ );
+ }
+
return [$email, $template, $websiteId];
}
}
diff --git a/app/code/Magento/Security/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Security/Test/Unit/Model/ConfigTest.php
index 7186502df73b5..3ef8655539b5a 100644
--- a/app/code/Magento/Security/Test/Unit/Model/ConfigTest.php
+++ b/app/code/Magento/Security/Test/Unit/Model/ConfigTest.php
@@ -167,7 +167,7 @@ protected function getXmlPathPrefix($scope)
if ($scope == \Magento\Framework\App\Area::AREA_ADMINHTML) {
return \Magento\Security\Model\Config::XML_PATH_ADMIN_AREA;
}
- return \Magento\Security\Model\Config::XML_PATH_FRONTED_AREA;
+ return \Magento\Security\Model\Config::XML_PATH_FRONTEND_AREA;
}
/**
diff --git a/app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php b/app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php
index 0935dc003d5b3..8f8128d395a0c 100644
--- a/app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php
+++ b/app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php
@@ -6,7 +6,11 @@
namespace Magento\Security\Test\Unit\Model\Plugin;
+use Magento\Customer\Model\AccountManagement;
+use Magento\Framework\App\Area;
+use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Security\Model\PasswordResetRequestEvent;
/**
* Test class for \Magento\Security\Model\Plugin\AccountManagement testing
@@ -19,20 +23,25 @@ class AccountManagementTest extends \PHPUnit\Framework\TestCase
protected $model;
/**
- * @var \Magento\Framework\App\RequestInterface
+ * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $request;
/**
- * @var \Magento\Security\Model\SecurityManager
+ * @var \Magento\Security\Model\SecurityManager|\PHPUnit_Framework_MockObject_MockObject
*/
protected $securityManager;
/**
- * @var \Magento\Customer\Model\AccountManagement
+ * @var AccountManagement|\PHPUnit_Framework_MockObject_MockObject
*/
protected $accountManagement;
+ /**
+ * @var ScopeInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $scope;
+
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
@@ -46,35 +55,45 @@ public function setUp()
{
$this->objectManager = new ObjectManager($this);
- $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
+ $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
$this->securityManager = $this->createPartialMock(
\Magento\Security\Model\SecurityManager::class,
['performSecurityCheck']
);
- $this->accountManagement = $this->createMock(\Magento\Customer\Model\AccountManagement::class);
+ $this->accountManagement = $this->createMock(AccountManagement::class);
+ $this->scope = $this->createMock(ScopeInterface::class);
+ }
+
+ /**
+ * @param $area
+ * @param $passwordRequestEvent
+ * @param $expectedTimes
+ * @dataProvider beforeInitiatePasswordResetDataProvider
+ */
+ public function testBeforeInitiatePasswordReset($area, $passwordRequestEvent, $expectedTimes)
+ {
+ $email = 'test@example.com';
+ $template = AccountManagement::EMAIL_RESET;
$this->model = $this->objectManager->getObject(
\Magento\Security\Model\Plugin\AccountManagement::class,
[
+ 'passwordRequestEvent' => $passwordRequestEvent,
'request' => $this->request,
- 'securityManager' => $this->securityManager
+ 'securityManager' => $this->securityManager,
+ 'scope' => $this->scope
]
);
- }
- /**
- * @return void
- */
- public function testBeforeInitiatePasswordReset()
- {
- $email = 'test@example.com';
- $template = \Magento\Customer\Model\AccountManagement::EMAIL_RESET;
+ $this->scope->expects($this->once())
+ ->method('getCurrentScope')
+ ->willReturn($area);
- $this->securityManager->expects($this->once())
+ $this->securityManager->expects($this->exactly($expectedTimes))
->method('performSecurityCheck')
- ->with(\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, $email)
+ ->with($passwordRequestEvent, $email)
->willReturnSelf();
$this->model->beforeInitiatePasswordReset(
@@ -83,4 +102,18 @@ public function testBeforeInitiatePasswordReset()
$template
);
}
+
+ /**
+ * @return array
+ */
+ public function beforeInitiatePasswordResetDataProvider()
+ {
+ return [
+ [Area::AREA_ADMINHTML, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 0],
+ [Area::AREA_ADMINHTML, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
+ [Area::AREA_FRONTEND, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
+ // This should never happen, but let's cover it with tests
+ [Area::AREA_FRONTEND, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
+ ];
+ }
}
diff --git a/app/code/Magento/Security/etc/adminhtml/di.xml b/app/code/Magento/Security/etc/adminhtml/di.xml
index 6f07fb580490e..c1188c2d405cf 100644
--- a/app/code/Magento/Security/etc/adminhtml/di.xml
+++ b/app/code/Magento/Security/etc/adminhtml/di.xml
@@ -17,7 +17,7 @@
- Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST
+ Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
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 db2053efd41f6..e6a29177301dd 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 5a5abfd828d88..c0a04a3fb45f6 100644
--- a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateTest.php
+++ b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateTest.php
@@ -46,7 +46,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/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/ResourceModel/BookmarkRepositoryTest.php b/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php
index 00a88437c8cb1..a0cec2258d658 100644
--- a/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php
+++ b/app/code/Magento/Ui/Test/Unit/Model/ResourceModel/BookmarkRepositoryTest.php
@@ -94,7 +94,8 @@ public function testSaveWithException()
->method('save')
->with($this->bookmarkMock)
->willThrowException(new \Exception($exceptionMessage));
- $this->expectException(\Magento\Framework\Exception\CouldNotSaveException::class, __($exceptionMessage));
+ $this->expectException(\Magento\Framework\Exception\CouldNotSaveException::class);
+ $this->expectExceptionMessage($exceptionMessage);
$this->bookmarkRepository->save($this->bookmarkMock);
}
@@ -143,7 +144,8 @@ public function testDeleteWithException()
->method('delete')
->with($this->bookmarkMock)
->willThrowException(new \Exception($exceptionMessage));
- $this->expectException(\Magento\Framework\Exception\CouldNotDeleteException::class, __($exceptionMessage));
+ $this->expectException(\Magento\Framework\Exception\CouldNotDeleteException::class);
+ $this->expectExceptionMessage($exceptionMessage);
$this->assertTrue($this->bookmarkRepository->delete($this->bookmarkMock));
}
diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php
index 1f8260c93c574..dc061aeea99e7 100644
--- a/app/code/Magento/Webapi/Controller/Rest.php
+++ b/app/code/Magento/Webapi/Controller/Rest.php
@@ -303,7 +303,7 @@ protected function processSchemaRequest()
$responseBody = $this->swaggerGenerator->generate(
$requestedServices,
$this->_request->getScheme(),
- $this->_request->getHttpHost(),
+ $this->_request->getHttpHost(false),
$this->_request->getRequestUri()
);
$this->_response->setBody($responseBody)->setHeader('Content-Type', 'application/json');
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 9e220091d6c2e..8ba8afaa1a8ab 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
@@ -82,7 +82,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/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php
index 95e65a1740b72..0b1057683de86 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php
@@ -299,7 +299,8 @@ public function testSetAndSaveItemOptions()
public function testGetProductWithException()
{
- $this->expectException(\Magento\Framework\Exception\LocalizedException::class, __('Cannot specify product.'));
+ $this->expectException(\Magento\Framework\Exception\LocalizedException::class);
+ $this->expectExceptionMessage('Cannot specify product.');
$this->model->getProduct();
}
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 ca9ad9897bf8c..17bc1226d992c 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php
@@ -609,9 +609,11 @@ public function testGetListForAbsentSku()
'sku' => $productSku,
];
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
- $this->expectException('SoapFault', 'Requested product doesn\'t exist');
+ $this->expectException('SoapFault');
+ $this->expectExceptionMessage('Requested product doesn\'t exist');
} else {
- $this->expectException('Exception', '', 404);
+ $this->expectException('Exception');
+ $this->expectExceptionCode(404);
}
$this->_webApiCall($serviceInfo, $requestData);
}
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 a152167a345fa..34588c9573f98 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php
@@ -211,12 +211,15 @@ public function testAddNegative($optionData)
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
if (isset($optionDataPost['title']) && empty($optionDataPost['title'])) {
- $this->expectException('SoapFault', 'Missed values for option required fields');
+ $this->expectException('SoapFault');
+ $this->expectExceptionMessage('Missed values for option required fields');
} else {
- $this->expectException('SoapFault', 'Invalid option');
+ $this->expectException('SoapFault');
+ $this->expectExceptionMessage('Invalid option');
}
} else {
- $this->expectException('Exception', '', 400);
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('', 400);
}
$this->_webApiCall($serviceInfo, ['option' => $optionDataPost]);
}
@@ -388,8 +391,9 @@ public function validOptionDataProvider()
* @dataProvider optionNegativeUpdateDataProvider
* @param array $optionData
* @param string $message
+ * @param int $exceptionCode
*/
- public function testUpdateNegative($optionData, $message)
+ public function testUpdateNegative($optionData, $message, $exceptionCode)
{
$this->_markTestAsRestOnly();
$productSku = 'simple';
@@ -406,7 +410,9 @@ public function testUpdateNegative($optionData, $message)
],
];
- $this->expectException('Exception', $message, 400);
+ $this->expectException('Exception');
+ $this->expectExceptionMessage($message);
+ $this->expectExceptionCode($exceptionCode);
$this->_webApiCall($serviceInfo, ['option' => $optionData]);
}
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 cd9aaa1d95294..cb33edce3af39 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
@@ -313,7 +313,8 @@ public function testDeleteAllStoreCode($fixtureProduct)
{
$sku = $fixtureProduct[ProductInterface::SKU];
$this->saveProduct($fixtureProduct);
- $this->expectException('Exception', 'Requested product doesn\'t exist');
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('Requested product doesn\'t exist');
// Delete all with 'all' store code
$this->deleteProduct($sku);
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_update_negative.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_update_negative.php
index 1e713424f8047..d819fb5f604bf 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_update_negative.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_update_negative.php
@@ -5,18 +5,31 @@
*/
return [
- 'missed_product_sku' =>
+ 'missing_product_sku' => [
[
- [
- 'title' => 'title',
- 'type' => 'field',
- 'sort_order' => 1,
- 'is_require' => 1,
- 'price' => 10.0,
- 'price_type' => 'fixed',
- 'sku' => 'sku1',
- 'max_characters' => 10,
- ],
- 'ProductSku should be specified',
- ]
+ 'title' => 'title',
+ 'type' => 'field',
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'price' => 10.0,
+ 'price_type' => 'fixed',
+ 'max_characters' => 10,
+ ],
+ 'ProductSku should be specified',
+ 400
+ ],
+ 'invalid_product_sku' => [
+ [
+ 'title' => 'title',
+ 'type' => 'field',
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'price' => 10.0,
+ 'price_type' => 'fixed',
+ 'product_sku' => 'sku1',
+ 'max_characters' => 10,
+ ],
+ 'Requested product doesn\'t exist',
+ 404
+ ],
];
diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php
index 48cc8b8384d74..452a59d7e702c 100644
--- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php
@@ -8,16 +8,12 @@
use Magento\Customer\Api\Data\CustomerInterface as Customer;
use Magento\Customer\Model\AccountManagement;
use Magento\Framework\Exception\InputException;
-use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
+use Magento\Newsletter\Model\Subscriber;
+use Magento\Security\Model\Config;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Helper\Customer as CustomerHelper;
use Magento\TestFramework\TestCase\WebapiAbstract;
-use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
-use Magento\Security\Model\Config;
-use Magento\Newsletter\Model\Plugin\CustomerPlugin;
-use Magento\Framework\Webapi\Rest\Request as RestRequest;
-use Magento\Newsletter\Model\Subscriber;
-use Magento\Customer\Model\Data\Customer as CustomerData;
/**
* Test class for Magento\Customer\Api\AccountManagementInterface
@@ -112,16 +108,16 @@ public function setUp()
$this->initSubscriber();
if ($this->config->getConfigDataValue(
- Config::XML_PATH_FRONTED_AREA .
+ Config::XML_PATH_FRONTEND_AREA .
Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE
) != 0) {
$this->configValue = $this->config
->getConfigDataValue(
- Config::XML_PATH_FRONTED_AREA .
+ Config::XML_PATH_FRONTEND_AREA .
Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE
);
$this->config->setDataByPath(
- Config::XML_PATH_FRONTED_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
+ Config::XML_PATH_FRONTEND_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
0
);
$this->config->save();
@@ -150,7 +146,7 @@ public function tearDown()
}
}
$this->config->setDataByPath(
- Config::XML_PATH_FRONTED_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
+ Config::XML_PATH_FRONTEND_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
$this->configValue
);
$this->config->save();
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 89533a0a62474..23b889c7c1251 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/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
new file mode 100644
index 0000000000000..4e8eaf70824db
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
@@ -0,0 +1,68 @@
+get(PluginList::class)
+ ->get(AttributeSetRepositoryInterface::class, []);
+ self::assertSame(RemoveProducts::class, $pluginInfo['remove_products']['instance']);
+ }
+
+ /**
+ * Test related to given attribute set products will be removed, if attribute set will be deleted.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_with_product.php
+ */
+ public function testAfterDelete()
+ {
+ $attributeSet = Bootstrap::getObjectManager()->get(Set::class);
+ $attributeSet->load('empty_attribute_set', 'attribute_set_name');
+
+ $productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
+ $product = $productRepository->get('simple');
+
+ $productCollection = Bootstrap::getObjectManager()->get(CollectionFactory::class)->create();
+ $productCollection->addIdFilter($product->getId());
+ $urlRewriteCollection = Bootstrap::getObjectManager()->get(UrlRewriteCollectionFactory::class)->create();
+ $urlRewriteCollection->addFieldToFilter('entity_type', 'product');
+ $urlRewriteCollection->addFieldToFilter('entity_id', $product->getId());
+
+ self::assertSame(1, $urlRewriteCollection->getSize());
+ self::assertSame(1, $productCollection->getSize());
+
+ $attributeSetRepository = Bootstrap::getObjectManager()->get(AttributeSetRepositoryInterface::class);
+ $attributeSetRepository->deleteById($attributeSet->getAttributeSetId());
+
+ $productCollection = Bootstrap::getObjectManager()->get(CollectionFactory::class)->create();
+ $productCollection->addIdFilter($product->getId());
+ $urlRewriteCollection = Bootstrap::getObjectManager()->get(UrlRewriteCollectionFactory::class)->create();
+ $urlRewriteCollection->addFieldToFilter('entity_type', 'product');
+ $urlRewriteCollection->addFieldToFilter('entity_id', $product->getId());
+
+ self::assertSame(0, $urlRewriteCollection->getSize());
+ self::assertSame(0, $productCollection->getSize());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_product.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_product.php
new file mode 100644
index 0000000000000..95f277c7124bd
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_product.php
@@ -0,0 +1,11 @@
+setAttributeSetId($attributeSet->getId());
+$product->save();
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_product_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_product_rollback.php
new file mode 100644
index 0000000000000..cd579bdb76f57
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_product_rollback.php
@@ -0,0 +1,8 @@
+assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
}
+ /**
+ * Checks reset password functionality with default restrictive min time between
+ * password reset requests and customer reset request event.
+ * Admin is not affected by this security check, so reset password email must be sent.
+ *
+ * @magentoConfigFixture current_store customer/password/max_number_password_reset_requests 0
+ * @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 10
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testResetPasswordMinTimeError()
+ {
+ $this->passwordResetRequestEventCreate(
+ \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
+ );
+ $this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->dispatch('backend/customer/index/resetPassword');
+ $this->assertSessionMessages(
+ $this->equalTo(['The customer will receive an email with a link to reset password.']),
+ \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
+ );
+ $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
+ }
+
+ /**
+ * Checks reset password functionality with default restrictive limited number
+ * password reset requests and customer reset request event.
+ * Admin is not affected by this security check, so reset password email must be sent.
+ *
+ * @magentoConfigFixture current_store customer/password/max_number_password_reset_requests 1
+ * @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testResetPasswordLimitError()
+ {
+ $this->passwordResetRequestEventCreate(
+ \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
+ );
+ $this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->dispatch('backend/customer/index/resetPassword');
+ $this->assertSessionMessages(
+ $this->equalTo(['The customer will receive an email with a link to reset password.']),
+ \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
+ );
+ $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
+ }
+
/**
* Checks reset password functionality with default settings, customer and admin reset request events.
*
- * @magentoConfigFixture current_store admin/security/limit_password_reset_requests_method 1
- * @magentoConfigFixture current_store admin/security/min_time_between_password_reset_requests 10
+ * @magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 1
+ * @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 10
* @magentoConfigFixture current_store contact/email/recipient_email hello@example.com
* @magentoDataFixture Magento/Customer/_files/customer.php
*/
@@ -59,10 +106,8 @@ public function testResetPasswordWithSecurityViolationException()
$this->getRequest()->setPostValue(['customer_id' => '1']);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertSessionMessages(
- $this->equalTo(
- ['Too many password reset requests. Please wait and try again or contact hello@example.com.']
- ),
- \Magento\Framework\Message\MessageInterface::TYPE_ERROR
+ $this->equalTo(['The customer will receive an email with a link to reset password.']),
+ \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
);
$this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
}
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/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/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/ResolverTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/ResolverTest.php
index f4560ed31ae49..33b6ab7e99aed 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/ResolverTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/ResolverTest.php
@@ -40,7 +40,8 @@ protected function setUp()
public function testGetTagsForNotObject()
{
- $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('some scalar');
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/DummyTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/DummyTest.php
index ad04326064587..4f072e037f74e 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/DummyTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/DummyTest.php
@@ -20,7 +20,8 @@ protected function setUp()
public function testGetTagsWithScalar()
{
- $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');
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/FactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/FactoryTest.php
index 8964bd70f0ba8..3e96c7ab9ca6c 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/FactoryTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/FactoryTest.php
@@ -49,7 +49,8 @@ protected function setUp()
public function testGetStrategyWithScalar()
{
- $this->expectException(\InvalidArgumentException::class, 'Provided argument is not an object');
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Provided argument is not an object');
$this->model->getStrategy('some scalar');
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/IdentifierTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/IdentifierTest.php
index d0fcf9d8a739d..4dc46d46e675e 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/IdentifierTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Tag/Strategy/IdentifierTest.php
@@ -22,7 +22,8 @@ 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');
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php
index 5301255818800..daf3a4bdfab0c 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/ErrorHandlerTest.php
@@ -54,7 +54,8 @@ public function testHandlerException($errorNo, $errorPhrase)
$errorLine = 'test_error_line';
$exceptedExceptionMessage = sprintf('%s: %s in %s on line %s', $errorPhrase, $errorStr, $errorFile, $errorLine);
- $this->expectException('Exception', $exceptedExceptionMessage);
+ $this->expectException('Exception');
+ $this->expectExceptionMessage($exceptedExceptionMessage);
$this->object->handler($errorNo, $errorStr, $errorFile, $errorLine);
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php b/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php
index a209c313a0a89..3db75f7ec7fb2 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/SetupInfoTest.php
@@ -24,7 +24,8 @@ class SetupInfoTest extends \PHPUnit\Framework\TestCase
*/
public function testConstructorExceptions($server, $expectedError)
{
- $this->expectException('\InvalidArgumentException', $expectedError);
+ $this->expectException('\InvalidArgumentException');
+ $this->expectExceptionMessage($expectedError);
new SetupInfo($server);
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php
index 9eed1fbedd954..65ac19cbc2996 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/ShellTest.php
@@ -69,7 +69,8 @@ public function testExecuteFailure()
);
$this->driverMock->expects($this->once())->method('execute')->willReturn($response);
$this->loggerMock->expects($this->once())->method('error')->with($logEntry);
- $this->expectException(LocalizedException::class, "Command returned non-zero exit code:\n`$command`");
+ $this->expectException(LocalizedException::class);
+ $this->expectExceptionMessage("Command returned non-zero exit code:\n`$command`");
$this->model->execute($command, []);
}
}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php
index c7a2764545357..1873cc593a655 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Asset/MaterializationStrategy/FactoryTest.php
@@ -87,7 +87,8 @@ public function testCreateException()
$factory = new Factory($this->objectManager, []);
- $this->expectException('LogicException', 'No materialization strategy is supported');
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage('No materialization strategy is supported');
$factory->create($asset);
}
diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php
index ee00a2154f415..129fade7b4a9c 100644
--- a/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php
+++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Frontend/Adapter/ZendTest.php
@@ -80,7 +80,8 @@ public function proxyMethodDataProvider()
*/
public function testCleanException($cleaningMode, $expectedErrorMessage)
{
- $this->expectException('InvalidArgumentException', $expectedErrorMessage);
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage($expectedErrorMessage);
$object = new \Magento\Framework\Cache\Frontend\Adapter\Zend($this->createMock(\Zend_Cache_Core::class));
$object->clean($cleaningMode);
}
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php
index 347bc6b46ace5..0f3daa46e1ec3 100644
--- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/InterfaceGeneratorTest.php
@@ -75,7 +75,8 @@ protected function setUp()
public function testGenerate($additionalMethodsData, $expectedException, $expectedExceptionMessage)
{
if ($expectedException) {
- $this->expectException($expectedException, $expectedExceptionMessage);
+ $this->expectException($expectedException);
+ $this->expectExceptionMessage($expectedExceptionMessage);
}
$methodsData = array_merge_recursive($this->methodsData, $additionalMethodsData);
$this->interfaceGenerator->setClassDocBlock($this->interfaceDocBlock)
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php
index bc23ef954f216..9c63de1258d15 100644
--- a/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/Generator/IoTest.php
@@ -97,7 +97,8 @@ public function testWriteResultFileAlreadyExists($resultFileName, $fileExists, $
} else {
$exceptionMessage = 'Some error renaming file';
$renameMockEvent = $this->throwException(new FileSystemException(new Phrase($exceptionMessage)));
- $this->expectException(\Magento\Framework\Exception\FileSystemException::class, $exceptionMessage);
+ $this->expectException(\Magento\Framework\Exception\FileSystemException::class);
+ $this->expectExceptionMessage($exceptionMessage);
}
$this->_filesystemDriverMock->expects($this->once())
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php
index d1692fd4ec012..96be42658f762 100644
--- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/ArgumentSequenceTest.php
@@ -51,7 +51,8 @@ public function testInvalidSequence()
'Actual : %s' .
PHP_EOL;
$message = sprintf($message, '\ArgumentSequence\InvalidChildClass', $expectedSequence, $actualSequence);
- $this->expectException(\Magento\Framework\Exception\ValidatorException::class, $message);
+ $this->expectException(\Magento\Framework\Exception\ValidatorException::class);
+ $this->expectExceptionMessage($message);
$this->_validator->validate('\ArgumentSequence\InvalidChildClass');
}
}
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php
index 3822d148adca5..a82c88e3e18b1 100644
--- a/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/Validator/TypeDuplicationTest.php
@@ -49,7 +49,8 @@ public function testInvalidClass()
$this->_fixturePath .
PHP_EOL .
'Multiple type injection [\TypeDuplication\ArgumentBaseClass]';
- $this->expectException(\Magento\Framework\Exception\ValidatorException::class, $message);
+ $this->expectException(\Magento\Framework\Exception\ValidatorException::class);
+ $this->expectExceptionMessage($message);
$this->_validator->validate('\TypeDuplication\InvalidClassWithDuplicatedTypes');
}
}
diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php
index b222f52dc738b..619135f9c7038 100644
--- a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php
+++ b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ConfigDataTest.php
@@ -42,7 +42,8 @@ public function testSetWrongKey($key, $expectedException)
$configData = new ConfigData('testKey');
- $this->expectException('InvalidArgumentException', $expectedException);
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage($expectedException);
$configData->set($key, 'value');
}
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 8d3623d485b89..92c901f3872f2 100644
--- a/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php
+++ b/lib/internal/Magento/Framework/DB/Test/Unit/Tree/NodeTest.php
@@ -20,7 +20,8 @@ public function testConstructorWithInvalidArgumentsThrowsException(
$expectedException,
$expectedExceptionMessage
) {
- $this->expectException($expectedException, $expectedExceptionMessage);
+ $this->expectException($expectedException);
+ $this->expectExceptionMessage($expectedExceptionMessage);
new \Magento\Framework\DB\Tree\Node($data['node_data'], $data['keys']);
}
diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php
index 768b8d3b9efa2..bca8bb0d9347f 100644
--- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php
+++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/Interpreter/CompositeTest.php
@@ -55,7 +55,8 @@ public function testConstructWrongInterpreter()
*/
public function testEvaluateWrongDiscriminator($input, $expectedExceptionMessage)
{
- $this->expectException('\InvalidArgumentException', $expectedExceptionMessage);
+ $this->expectException('\InvalidArgumentException');
+ $this->expectExceptionMessage($expectedExceptionMessage);
$this->_model->evaluate($input);
}
diff --git a/lib/internal/Magento/Framework/File/Uploader.php b/lib/internal/Magento/Framework/File/Uploader.php
index c3316db7be016..07de9941271c3 100644
--- a/lib/internal/Magento/Framework/File/Uploader.php
+++ b/lib/internal/Magento/Framework/File/Uploader.php
@@ -201,7 +201,7 @@ public function save($destinationFolder, $newFileName = null)
if ($this->_enableFilesDispersion) {
$fileName = $this->correctFileNameCase($fileName);
$this->setAllowCreateFolders(true);
- $this->_dispretionPath = self::getDispretionPath($fileName);
+ $this->_dispretionPath = self::getDispersionPath($fileName);
$destinationFile .= $this->_dispretionPath;
$this->_createDestinationFolder($destinationFile);
}
@@ -610,8 +610,20 @@ public static function getNewFileName($destinationFile)
*
* @param string $fileName
* @return string
+ * @deprecated
*/
public static function getDispretionPath($fileName)
+ {
+ return self::getDispersionPath($fileName);
+ }
+
+ /**
+ * Get dispertion path
+ *
+ * @param string $fileName
+ * @return string
+ */
+ public static function getDispersionPath($fileName)
{
$char = 0;
$dispertionPath = '';
diff --git a/lib/internal/Magento/Framework/Filesystem/Test/Unit/DirectoryListTest.php b/lib/internal/Magento/Framework/Filesystem/Test/Unit/DirectoryListTest.php
index 8a96f79179bd7..96b56de8451c2 100644
--- a/lib/internal/Magento/Framework/Filesystem/Test/Unit/DirectoryListTest.php
+++ b/lib/internal/Magento/Framework/Filesystem/Test/Unit/DirectoryListTest.php
@@ -21,7 +21,8 @@ public function testGetDefaultConfig()
*/
public function testValidate($config, $expectedError)
{
- $this->expectException('\InvalidArgumentException', $expectedError);
+ $this->expectException('\InvalidArgumentException');
+ $this->expectExceptionMessage($expectedError);
DirectoryList::validate($config);
}
diff --git a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php
index af44ae45c2cc5..ae0348f489fd2 100644
--- a/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php
+++ b/lib/internal/Magento/Framework/Image/Test/Unit/Adapter/ImageMagickTest.php
@@ -58,7 +58,8 @@ public function setup()
*/
public function testWatermark($imagePath, $expectedMessage)
{
- $this->expectException('LogicException', $expectedMessage);
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage($expectedMessage);
$this->imageMagic->watermark($imagePath);
}
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 e278de0fff914..c91b56560eb75 100644
--- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php
+++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/ChangelogTest.php
@@ -124,7 +124,8 @@ public function testGetVersionWithExceptionNoTable()
$this->mockIsTableExists($changelogTableName, false);
$this->mockGetTableName();
- $this->expectException('Exception', "Table {$changelogTableName} does not exist");
+ $this->expectException('Exception');
+ $this->expectExceptionMessage("Table {$changelogTableName} does not exist");
$this->model->setViewId('viewIdtest');
$this->model->getVersion();
}
@@ -135,7 +136,8 @@ public function testDrop()
$this->mockIsTableExists($changelogTableName, false);
$this->mockGetTableName();
- $this->expectException('Exception', "Table {$changelogTableName} does not exist");
+ $this->expectException('Exception');
+ $this->expectExceptionMessage("Table {$changelogTableName} does not exist");
$this->model->setViewId('viewIdtest');
$this->model->drop();
}
@@ -226,7 +228,8 @@ public function testGetListWithException()
$this->mockIsTableExists($changelogTableName, false);
$this->mockGetTableName();
- $this->expectException('Exception', "Table {$changelogTableName} does not exist");
+ $this->expectException('Exception');
+ $this->expectExceptionMessage("Table {$changelogTableName} does not exist");
$this->model->setViewId('viewIdtest');
$this->model->getList(mt_rand(1, 200), mt_rand(201, 400));
}
@@ -237,7 +240,8 @@ public function testClearWithException()
$this->mockIsTableExists($changelogTableName, false);
$this->mockGetTableName();
- $this->expectException('Exception', "Table {$changelogTableName} does not exist");
+ $this->expectException('Exception');
+ $this->expectExceptionMessage("Table {$changelogTableName} does not exist");
$this->model->setViewId('viewIdtest');
$this->model->clear(mt_rand(1, 200));
}
diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php
index 57d8841455fd7..e302dc8f5ad5e 100644
--- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php
+++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/CompositeTest.php
@@ -85,7 +85,8 @@ public function testRenderException()
->method('render')
->willThrowException($exception);
- $this->expectException('Exception', $message);
+ $this->expectException('Exception');
+ $this->expectExceptionMessage($message);
$this->object->render(['text'], []);
}
}
diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php
index 793557000fb1e..f9b6e47c19a86 100644
--- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php
+++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/InlineTest.php
@@ -88,7 +88,8 @@ public function testRenderException()
->method('get')
->willThrowException($exception);
- $this->expectException('Exception', $message);
+ $this->expectException('Exception');
+ $this->expectExceptionMessage($message);
$this->renderer->render(['text'], []);
}
}
diff --git a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php
index fb4b3232cab31..d8a0b3673ad6d 100644
--- a/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php
+++ b/lib/internal/Magento/Framework/Phrase/Test/Unit/Renderer/TranslateTest.php
@@ -91,7 +91,8 @@ public function testRenderException()
->method('getData')
->willThrowException($exception);
- $this->expectException('Exception', $message);
+ $this->expectException('Exception');
+ $this->expectExceptionMessage($message);
$this->_renderer->render(['text'], []);
}
}
diff --git a/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php b/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php
index 201856124d721..1516f65479771 100644
--- a/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php
+++ b/lib/internal/Magento/Framework/Test/Unit/Module/Plugin/DbStatusValidatorTest.php
@@ -114,7 +114,7 @@ public function testBeforeDispatchOutOfDateWithErrors(array $errors, string $exp
$this->cacheMock->expects(static::never())
->method('save');
- $this->expectException(LocalizedException::class, $expectedMessage);
+ $this->expectException(LocalizedException::class);
$this->expectExceptionMessage($expectedMessage);
$this->plugin->beforeDispatch($this->frontControllerMock, $this->requestMock);
}
diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php
index 2df8d535ee788..860d449c4717e 100644
--- a/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php
+++ b/lib/internal/Magento/Framework/Validator/Test/Unit/BuilderTest.php
@@ -341,7 +341,8 @@ protected function _getExpectedConstraints($constraint, $optionKey, $optionValue
*/
public function testConstructorConfigValidation(array $options, $exception, $exceptionMessage)
{
- $this->expectException($exception, $exceptionMessage);
+ $this->expectException($exception);
+ $this->expectExceptionMessage($exceptionMessage);
if (array_key_exists('method', $options)) {
$options = ['methods' => [$options]];
}
@@ -362,7 +363,8 @@ public function testConstructorConfigValidation(array $options, $exception, $exc
*/
public function testAddConfigurationConfigValidation(array $options, $exception, $exceptionMessage)
{
- $this->expectException($exception, $exceptionMessage);
+ $this->expectException($exception);
+ $this->expectExceptionMessage($exceptionMessage);
$constraints = [
['alias' => 'alias', 'class' => 'Some\Validator\Class', 'options' => null, 'type' => 'entity'],
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 91bd3a7608d67..9617b28383088 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
@@ -123,7 +123,8 @@ public function setArgumentsDataProvider()
public function testGetValueException($callback, $expectedMessage, $createInstance = false)
{
$option = new \Magento\Framework\Validator\Constraint\Option\Callback($callback, null, $createInstance);
- $this->expectException('InvalidArgumentException', $expectedMessage);
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage($expectedMessage);
$option->getValue();
}
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php
index 83813785886c5..b457a98b5e236 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/TemplateTest.php
@@ -175,7 +175,8 @@ public function testFetchViewWithNoFileNameDeveloperMode()
->method('getMode')
->willReturn(\Magento\Framework\App\State::MODE_DEVELOPER);
- $this->expectException(\Magento\Framework\Exception\ValidatorException::class, $exception);
+ $this->expectException(\Magento\Framework\Exception\ValidatorException::class);
+ $this->expectExceptionMessage($exception);
$this->block->fetchView($template);
}
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php
index d1a1851c06c52..cae621a09125f 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/File/Collector/Override/ThemeModularTest.php
@@ -169,7 +169,8 @@ public function testGetFilesWrongAncestor()
$filePath = 'design/area/theme_path/Module_One/override/theme/vendor/parent_theme/1.xml';
$expectedMessage = "Trying to override modular view file '$filePath' for theme 'vendor/parent_theme'"
. ", which is not ancestor of theme 'vendor/theme_path'";
- $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $expectedMessage);
+ $this->expectException(\Magento\Framework\Exception\LocalizedException::class);
+ $this->expectExceptionMessage($expectedMessage);
$theme = $this->getMockForAbstractClass(\Magento\Framework\View\Design\ThemeInterface::class);
$theme->expects($this->once())->method('getFullPath')->willReturn($themePath);
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php
index 19b450e2d4235..458b23a4b15eb 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/HelperMethodTest.php
@@ -67,7 +67,8 @@ public function help($input)
*/
public function testEvaluateException($helperMethod, $expectedExceptionMessage)
{
- $this->expectException('\InvalidArgumentException', $expectedExceptionMessage);
+ $this->expectException('\InvalidArgumentException');
+ $this->expectExceptionMessage($expectedExceptionMessage);
$input = ['value' => 'some text', 'helper' => $helperMethod];
$this->_model->evaluate($input);
}
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php
index 65f72ef96f850..5ae0b0332f28a 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/NamedParamsTest.php
@@ -62,7 +62,8 @@ public function testEvaluate()
*/
public function testEvaluateWrongParam($input, $expectedExceptionMessage)
{
- $this->expectException('\InvalidArgumentException', $expectedExceptionMessage);
+ $this->expectException('\InvalidArgumentException');
+ $this->expectExceptionMessage($expectedExceptionMessage);
$this->_model->evaluate($input);
}
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php
index 682106e01ad4e..7cc280a930d9c 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/ObjectTest.php
@@ -49,7 +49,8 @@ public function testEvaluate()
*/
public function testEvaluateWrongClass($input, $expectedException, $expectedExceptionMessage)
{
- $this->expectException($expectedException, $expectedExceptionMessage);
+ $this->expectException($expectedException);
+ $this->expectExceptionMessage($expectedExceptionMessage);
$self = $this;
$this->_objectManager->expects($this->any())->method('create')->willReturnCallback(
function ($className) use ($self) {
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php
index ffb79790d33f8..d3e91cb7c2b7e 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Argument/Interpreter/OptionsTest.php
@@ -67,7 +67,8 @@ public function testEvaluate()
*/
public function testEvaluateWrongModel($input, $expectedException, $expectedExceptionMessage)
{
- $this->expectException($expectedException, $expectedExceptionMessage);
+ $this->expectException($expectedException);
+ $this->expectExceptionMessage($expectedExceptionMessage);
$this->_model->evaluate($input);
}
diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php
index 71ede3fd4fcb4..d4177ceee8d7e 100644
--- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php
+++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php
@@ -55,7 +55,8 @@ protected function tearDown()
public function testDeserializerInvalidArgumentException()
{
- $this->expectException('InvalidArgumentException', '"boolean" data type is invalid. String is expected.');
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('"boolean" data type is invalid. String is expected.');
$this->_jsonDeserializer->deserialize(false);
}
diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php
index 2c754f23b0b5c..4b9c90de7355e 100644
--- a/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php
+++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/XmlTest.php
@@ -42,7 +42,8 @@ protected function tearDown()
public function testDeserializeInvalidArgumentException()
{
- $this->expectException('InvalidArgumentException', '"boolean" data type is invalid. String is expected.');
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('"boolean" data type is invalid. String is expected.');
$this->_xmlDeserializer->deserialize(false);
}
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 74d87095823f7..588a67430a61f 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
@@ -11,7 +11,8 @@ class DeserializerFactoryTest extends \PHPUnit\Framework\TestCase
{
public function testGetLogicExceptionEmptyRequestAdapter()
{
- $this->expectException('LogicException', 'Request deserializer adapter is not set.');
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage('Request deserializer adapter is not set.');
$interpreterFactory = new \Magento\Framework\Webapi\Rest\Request\DeserializerFactory(
$this->createMock(\Magento\Framework\ObjectManagerInterface::class),
[]
diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php
index dbe566f9a1c7a..7f0553034b4f9 100644
--- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ModificationChainTest.php
@@ -25,7 +25,8 @@ public function testConstructor()
public function testConstructorException()
{
- $this->expectException('InvalidArgumentException', 'Wrong modifier provided');
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Wrong modifier provided');
$modificationsList = [];
$modificationsList[] = $this->getMockBuilder(
\Magento\Setup\Module\Di\Compiler\Config\ModificationInterface::class
diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php
index cb49c3a33a5c5..331b2b8705c5b 100644
--- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/Options/ResolverTest.php
@@ -136,7 +136,8 @@ public function testGetOptionsWrongDir($directory, $withContext, $message)
'directoryList' => $directoryList
]
);
- $this->expectException('\InvalidArgumentException', $message);
+ $this->expectException('\InvalidArgumentException');
+ $this->expectExceptionMessage($message);
$resolver->getOptions();
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php
index e87a716ffdb62..b76cc4a0b1f1a 100644
--- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Dictionary/PhraseTest.php
@@ -55,7 +55,8 @@ public function dataProviderPhraseCreation()
*/
public function testWrongParametersWhilePhraseCreation($constructArguments, $message)
{
- $this->expectException('DomainException', $message);
+ $this->expectException('DomainException');
+ $this->expectExceptionMessage($message);
new Phrase(...array_values($constructArguments));
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php
index 3395596f399a3..1c035e8ceed82 100644
--- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Pack/GeneratorTest.php
@@ -111,7 +111,8 @@ public function testGenerateWithNotAllowedDuplicatesAndDuplicatesExist()
$error = "Duplicated translation is found, but it is not allowed.\n"
. "The phrase \"phrase1\" is translated in 1 places.\n"
. "The phrase \"phrase2\" is translated in 1 places.\n";
- $this->expectException('\RuntimeException', $error);
+ $this->expectException('\RuntimeException');
+ $this->expectExceptionMessage($error);
$allowDuplicates = false;
diff --git a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php
index e68a1c624376b..3c744bb44d32a 100644
--- a/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/AbstractParserTest.php
@@ -29,7 +29,8 @@ protected function setUp()
*/
public function testValidateOptions($options, $message)
{
- $this->expectException('InvalidArgumentException', $message);
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage($message);
$this->_parserMock->addAdapter(
'php',