Skip to content

Commit fb41335

Browse files
committed
#11363: Unmask exception message during product import
- Test updated
1 parent d3c8656 commit fb41335

File tree

1 file changed

+25
-0
lines changed
  • dev/tests/integration/testsuite/Magento/ImportExport/Model

1 file changed

+25
-0
lines changed

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)