@@ -98,6 +98,11 @@ class ImportTest extends \PHPUnit_Framework_TestCase
98
98
*/
99
99
protected $ _varDirectory ;
100
100
101
+ /**
102
+ * @var \Magento\Framework\Filesystem\DriverInterface|\PHPUnit_Framework_MockObject_MockObject
103
+ */
104
+ protected $ _driver ;
105
+
101
106
public function setUp ()
102
107
{
103
108
$ logger = $ this ->getMockBuilder ('\Psr\Log\LoggerInterface ' )
@@ -155,6 +160,17 @@ public function setUp()
155
160
$ this ->_varDirectory = $ this ->getMockBuilder ('\Magento\Framework\Filesystem\Directory\WriteInterface ' )
156
161
->disableOriginalConstructor ()
157
162
->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 );
158
174
$ this ->import = $ this ->getMockBuilder ('\Magento\ImportExport\Model\Import ' )
159
175
->setConstructorArgs ([
160
176
$ logger ,
@@ -550,13 +566,6 @@ public function testCreateHistoryReportSourceFileRelativeIsArray()
550
566
->method ('getRelativePath ' )
551
567
->with (\Magento \ImportExport \Model \Import::IMPORT_DIR . $ fileName )
552
568
->willReturn ($ sourceFileRelativeNew );
553
- $ this ->_varDirectory
554
- ->expects ($ this ->once ())
555
- ->method ('copyFile ' )
556
- ->with (
557
- $ sourceFileRelativeNew ,
558
- $ copyFile
559
- );
560
569
$ this ->dateTime
561
570
->expects ($ this ->once ())
562
571
->method ('gmtTimestamp ' )
@@ -600,13 +609,6 @@ public function testCreateHistoryReportSourceFileRelativeIsNotArrayResultIsSet()
600
609
$ this ->_varDirectory
601
610
->expects ($ this ->never ())
602
611
->method ('getRelativePath ' );
603
- $ this ->_varDirectory
604
- ->expects ($ this ->once ())
605
- ->method ('copyFile ' )
606
- ->with (
607
- $ sourceFileRelative ,
608
- $ copyFile
609
- );
610
612
$ this ->dateTime
611
613
->expects ($ this ->once ())
612
614
->method ('gmtTimestamp ' )
@@ -648,13 +650,6 @@ public function testCreateHistoryReportExtensionIsSet()
648
650
$ this ->_varDirectory
649
651
->expects ($ this ->never ())
650
652
->method ('getRelativePath ' );
651
- $ this ->_varDirectory
652
- ->expects ($ this ->once ())
653
- ->method ('copyFile ' )
654
- ->with (
655
- $ sourceFileRelative ,
656
- $ copyFile
657
- );
658
653
$ this ->dateTime
659
654
->expects ($ this ->once ())
660
655
->method ('gmtTimestamp ' )
@@ -697,20 +692,16 @@ public function testCreateHistoryReportThrowException()
697
692
->expects ($ this ->never ())
698
693
->method ('getRelativePath ' );
699
694
$ 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 ' )
703
698
->willReturnCallback (function () use ($ phrase ) {
704
699
throw new \Magento \Framework \Exception \FileSystemException ($ phrase );
705
700
});
706
701
$ this ->dateTime
707
702
->expects ($ this ->once ())
708
703
->method ('gmtTimestamp ' )
709
704
->willReturn ($ gmtTimestamp );
710
- $ this ->historyModel
711
- ->expects ($ this ->never ())
712
- ->method ('addReport ' );
713
-
714
705
$ args = [
715
706
$ sourceFileRelative ,
716
707
$ entity ,
0 commit comments