Skip to content

Commit e23e73b

Browse files
committed
MAGNIMEX-257: import history unit test fix
1 parent e53cfa1 commit e23e73b

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

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

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ 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+
101106
public function setUp()
102107
{
103108
$logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')
@@ -155,6 +160,17 @@ public function setUp()
155160
$this->_varDirectory = $this->getMockBuilder('\Magento\Framework\Filesystem\Directory\WriteInterface')
156161
->disableOriginalConstructor()
157162
->getMockForAbstractClass();
163+
$this->_driver = $this->getMockBuilder('\Magento\Framework\Filesystem\DriverInterface')
164+
->disableOriginalConstructor()
165+
->getMockForAbstractClass();
166+
$this->_driver
167+
->expects($this->any())
168+
->method('fileGetContents')
169+
->willReturn('');
170+
$this->_varDirectory
171+
->expects($this->any())
172+
->method('getDriver')
173+
->willReturn($this->_driver);
158174
$this->import = $this->getMockBuilder('\Magento\ImportExport\Model\Import')
159175
->setConstructorArgs([
160176
$logger,
@@ -550,13 +566,6 @@ public function testCreateHistoryReportSourceFileRelativeIsArray()
550566
->method('getRelativePath')
551567
->with(\Magento\ImportExport\Model\Import::IMPORT_DIR . $fileName)
552568
->willReturn($sourceFileRelativeNew);
553-
$this->_varDirectory
554-
->expects($this->once())
555-
->method('copyFile')
556-
->with(
557-
$sourceFileRelativeNew,
558-
$copyFile
559-
);
560569
$this->dateTime
561570
->expects($this->once())
562571
->method('gmtTimestamp')
@@ -600,13 +609,6 @@ public function testCreateHistoryReportSourceFileRelativeIsNotArrayResultIsSet()
600609
$this->_varDirectory
601610
->expects($this->never())
602611
->method('getRelativePath');
603-
$this->_varDirectory
604-
->expects($this->once())
605-
->method('copyFile')
606-
->with(
607-
$sourceFileRelative,
608-
$copyFile
609-
);
610612
$this->dateTime
611613
->expects($this->once())
612614
->method('gmtTimestamp')
@@ -648,13 +650,6 @@ public function testCreateHistoryReportExtensionIsSet()
648650
$this->_varDirectory
649651
->expects($this->never())
650652
->method('getRelativePath');
651-
$this->_varDirectory
652-
->expects($this->once())
653-
->method('copyFile')
654-
->with(
655-
$sourceFileRelative,
656-
$copyFile
657-
);
658653
$this->dateTime
659654
->expects($this->once())
660655
->method('gmtTimestamp')
@@ -697,20 +692,16 @@ public function testCreateHistoryReportThrowException()
697692
->expects($this->never())
698693
->method('getRelativePath');
699694
$phrase = $this->getMock('\Magento\Framework\Phrase', [], [], '', false);
700-
$this->_varDirectory
701-
->expects($this->once())
702-
->method('copyFile')
695+
$this->_driver
696+
->expects($this->any())
697+
->method('fileGetContents')
703698
->willReturnCallback(function () use ($phrase) {
704699
throw new \Magento\Framework\Exception\FileSystemException($phrase);
705700
});
706701
$this->dateTime
707702
->expects($this->once())
708703
->method('gmtTimestamp')
709704
->willReturn($gmtTimestamp);
710-
$this->historyModel
711-
->expects($this->never())
712-
->method('addReport');
713-
714705
$args = [
715706
$sourceFileRelative,
716707
$entity,

0 commit comments

Comments
 (0)