Skip to content

Commit eeb0e6f

Browse files
MAGETWO-81594: Issue magento#6924: Unmask exception message during product import magento#11363
2 parents ad775a8 + 9f5c923 commit eeb0e6f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

app/code/Magento/ImportExport/Model/Import.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ public function validateSource(\Magento\ImportExport\Model\Import\AbstractSource
567567
ProcessingError::ERROR_LEVEL_CRITICAL,
568568
null,
569569
null,
570-
null,
571570
$e->getMessage()
572571
);
573572
}

dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,31 @@ public function testValidateSourceException()
135135
$this->_model->validateSource($source);
136136
}
137137

138+
public function testValidateSourceExceptionMessage()
139+
{
140+
$exceptionMessage = 'Test Exception Message.';
141+
142+
$validationStrategy = ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_STOP_ON_ERROR;
143+
$this->_model->setEntity('catalog_product');
144+
$this->_model->setData(\Magento\ImportExport\Model\Import::FIELD_NAME_VALIDATION_STRATEGY, $validationStrategy);
145+
$this->_model->setData(\Magento\ImportExport\Model\Import::FIELD_NAME_ALLOWED_ERROR_COUNT, 0);
146+
147+
/** @var \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject $source */
148+
$source = $this->getMockForAbstractClass(
149+
\Magento\ImportExport\Model\Import\AbstractSource::class,
150+
[['sku', 'name']]
151+
);
152+
$source->expects($this->any())->method('_getNextRow')->willThrowException(
153+
new \Exception($exceptionMessage)
154+
);
155+
156+
$this->assertFalse($this->_model->validateSource($source));
157+
$this->assertEquals(
158+
$exceptionMessage,
159+
$this->_model->getErrorAggregator()->getAllErrors()[0]->getErrorMessage()
160+
);
161+
}
162+
138163
public function testGetEntity()
139164
{
140165
$entityName = 'entity_name';

0 commit comments

Comments
 (0)