Skip to content

Commit a413707

Browse files
Merge remote-tracking branch '32904/import-export/entity-values-are-mixed' into comm_jul
2 parents 5f6d6ab + 9825ce3 commit a413707

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,18 @@ private function validateSourceCallback(AbstractSource $source)
721721
$messages = $this->getOperationResultMessages($errorAggregator);
722722
$this->addLogComment($messages);
723723

724-
$result = !$errorAggregator->isErrorLimitExceeded();
725-
if ($result) {
726-
$this->addLogComment(__('Import data validation is complete.'));
724+
if ($errorAggregator->isErrorLimitExceeded()) {
725+
return false;
727726
}
728-
return $result;
727+
728+
if ($this->getProcessedRowsCount() <= $errorAggregator->getInvalidRowsCount()) {
729+
$this->addLogComment(__('There are no valid rows to import.'));
730+
return false;
731+
}
732+
733+
$this->addLogComment(__('Import data validation is complete.'));
734+
735+
return true;
729736
}
730737

731738
/**

app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public function testValidateSource()
509509
$this->errorAggregatorMock->expects($this->once())
510510
->method('initValidationStrategy')
511511
->with($validationStrategy, $allowedErrorCount);
512-
$this->errorAggregatorMock->expects($this->once())
512+
$this->errorAggregatorMock->expects($this->atLeastOnce())
513513
->method('getErrorsCount')
514514
->willReturn(0);
515515

@@ -527,7 +527,7 @@ public function testValidateSource()
527527
$this->import->expects($this->any())
528528
->method('_getEntityAdapter')
529529
->willReturn($this->_entityAdapter);
530-
$this->import->expects($this->once())
530+
$this->import->expects($this->atLeastOnce())
531531
->method('getProcessedRowsCount')
532532
->willReturn(0);
533533

@@ -541,12 +541,12 @@ public function testValidateSource()
541541
]
542542
);
543543

544-
$this->assertTrue($this->import->validateSource($csvMock));
544+
$this->assertFalse($this->import->validateSource($csvMock));
545545

546546
$logTrace = $this->import->getFormatedLogTrace();
547547
$this->assertStringContainsString('Begin data validation', $logTrace);
548548
$this->assertStringContainsString('This file does not contain any data', $logTrace);
549-
$this->assertStringContainsString('Import data validation is complete', $logTrace);
549+
$this->assertStringContainsString('There are no valid rows to import', $logTrace);
550550
}
551551

552552
public function testInvalidateIndex()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testValidateSource()
142142
[['sku', 'name']]
143143
);
144144
$source->expects($this->any())->method('_getNextRow')->willReturn(false);
145-
$this->assertTrue($this->_model->validateSource($source));
145+
$this->assertFalse($this->_model->validateSource($source));
146146
}
147147

148148
/**

0 commit comments

Comments
 (0)