Skip to content

Commit e2bb8f9

Browse files
author
Andrey Konosov
committed
Merge commit 'refs/pull/12/head' of https://github.com/magento/magento2ce into epam-4
2 parents b1a0ae3 + 5cec2e8 commit e2bb8f9

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,10 @@ public function isRowAllowedToImport(array $rowData, $rowNumber)
678678
}
679679

680680
/**
681-
* Is import need to log in history.
682-
*
683-
* @return bool
684-
*/
681+
* Is import need to log in history.
682+
*
683+
* @return bool
684+
*/
685685
public function isNeedToLogInHistory()
686686
{
687687
return $this->logInHistory;

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

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ class ImportTest extends \PHPUnit_Framework_TestCase
9898
*/
9999
protected $_varDirectory;
100100

101+
/**
102+
* @var \Magento\Framework\Filesystem\DriverInterface|\PHPUnit_Framework_MockObject_MockObject
103+
*/
104+
protected $_driver;
105+
106+
/**
107+
* Set up
108+
*
109+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
110+
*/
101111
public function setUp()
102112
{
103113
$logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')
@@ -155,6 +165,17 @@ public function setUp()
155165
$this->_varDirectory = $this->getMockBuilder('\Magento\Framework\Filesystem\Directory\WriteInterface')
156166
->disableOriginalConstructor()
157167
->getMockForAbstractClass();
168+
$this->_driver = $this->getMockBuilder('\Magento\Framework\Filesystem\DriverInterface')
169+
->disableOriginalConstructor()
170+
->getMockForAbstractClass();
171+
$this->_driver
172+
->expects($this->any())
173+
->method('fileGetContents')
174+
->willReturn('');
175+
$this->_varDirectory
176+
->expects($this->any())
177+
->method('getDriver')
178+
->willReturn($this->_driver);
158179
$this->import = $this->getMockBuilder('\Magento\ImportExport\Model\Import')
159180
->setConstructorArgs([
160181
$logger,
@@ -538,7 +559,6 @@ public function testCreateHistoryReportSourceFileRelativeIsArray()
538559
$fileName = $sourceFileRelative['file_name'];
539560
$gmtTimestamp = 1234567;
540561
$copyName = $gmtTimestamp . '_' . $fileName;
541-
$copyFile = \Magento\ImportExport\Model\Import::IMPORT_HISTORY_DIR . $copyName;
542562

543563
$this->import
544564
->expects($this->once())
@@ -550,13 +570,6 @@ public function testCreateHistoryReportSourceFileRelativeIsArray()
550570
->method('getRelativePath')
551571
->with(\Magento\ImportExport\Model\Import::IMPORT_DIR . $fileName)
552572
->willReturn($sourceFileRelativeNew);
553-
$this->_varDirectory
554-
->expects($this->once())
555-
->method('copyFile')
556-
->with(
557-
$sourceFileRelativeNew,
558-
$copyFile
559-
);
560573
$this->dateTime
561574
->expects($this->once())
562575
->method('gmtTimestamp')
@@ -590,7 +603,6 @@ public function testCreateHistoryReportSourceFileRelativeIsNotArrayResultIsSet()
590603
$fileName = $result['name'];
591604
$gmtTimestamp = 1234567;
592605
$copyName = $gmtTimestamp . '_' . $fileName;
593-
$copyFile = \Magento\ImportExport\Model\Import::IMPORT_HISTORY_DIR . $copyName;
594606

595607
$this->import
596608
->expects($this->once())
@@ -600,13 +612,6 @@ public function testCreateHistoryReportSourceFileRelativeIsNotArrayResultIsSet()
600612
$this->_varDirectory
601613
->expects($this->never())
602614
->method('getRelativePath');
603-
$this->_varDirectory
604-
->expects($this->once())
605-
->method('copyFile')
606-
->with(
607-
$sourceFileRelative,
608-
$copyFile
609-
);
610615
$this->dateTime
611616
->expects($this->once())
612617
->method('gmtTimestamp')
@@ -638,7 +643,6 @@ public function testCreateHistoryReportExtensionIsSet()
638643
$fileName = $entity . $extension;
639644
$gmtTimestamp = 1234567;
640645
$copyName = $gmtTimestamp . '_' . $fileName;
641-
$copyFile = \Magento\ImportExport\Model\Import::IMPORT_HISTORY_DIR . $copyName;
642646

643647
$this->import
644648
->expects($this->once())
@@ -648,13 +652,6 @@ public function testCreateHistoryReportExtensionIsSet()
648652
$this->_varDirectory
649653
->expects($this->never())
650654
->method('getRelativePath');
651-
$this->_varDirectory
652-
->expects($this->once())
653-
->method('copyFile')
654-
->with(
655-
$sourceFileRelative,
656-
$copyFile
657-
);
658655
$this->dateTime
659656
->expects($this->once())
660657
->method('gmtTimestamp')
@@ -697,20 +694,16 @@ public function testCreateHistoryReportThrowException()
697694
->expects($this->never())
698695
->method('getRelativePath');
699696
$phrase = $this->getMock('\Magento\Framework\Phrase', [], [], '', false);
700-
$this->_varDirectory
701-
->expects($this->once())
702-
->method('copyFile')
697+
$this->_driver
698+
->expects($this->any())
699+
->method('fileGetContents')
703700
->willReturnCallback(function () use ($phrase) {
704701
throw new \Magento\Framework\Exception\FileSystemException($phrase);
705702
});
706703
$this->dateTime
707704
->expects($this->once())
708705
->method('gmtTimestamp')
709706
->willReturn($gmtTimestamp);
710-
$this->historyModel
711-
->expects($this->never())
712-
->method('addReport');
713-
714707
$args = [
715708
$sourceFileRelative,
716709
$entity,

0 commit comments

Comments
 (0)