@@ -98,6 +98,16 @@ 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
+
106
+ /**
107
+ * Set up
108
+ *
109
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
110
+ */
101
111
public function setUp ()
102
112
{
103
113
$ logger = $ this ->getMockBuilder ('\Psr\Log\LoggerInterface ' )
@@ -155,6 +165,17 @@ public function setUp()
155
165
$ this ->_varDirectory = $ this ->getMockBuilder ('\Magento\Framework\Filesystem\Directory\WriteInterface ' )
156
166
->disableOriginalConstructor ()
157
167
->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 );
158
179
$ this ->import = $ this ->getMockBuilder ('\Magento\ImportExport\Model\Import ' )
159
180
->setConstructorArgs ([
160
181
$ logger ,
@@ -538,7 +559,6 @@ public function testCreateHistoryReportSourceFileRelativeIsArray()
538
559
$ fileName = $ sourceFileRelative ['file_name ' ];
539
560
$ gmtTimestamp = 1234567 ;
540
561
$ copyName = $ gmtTimestamp . '_ ' . $ fileName ;
541
- $ copyFile = \Magento \ImportExport \Model \Import::IMPORT_HISTORY_DIR . $ copyName ;
542
562
543
563
$ this ->import
544
564
->expects ($ this ->once ())
@@ -550,13 +570,6 @@ public function testCreateHistoryReportSourceFileRelativeIsArray()
550
570
->method ('getRelativePath ' )
551
571
->with (\Magento \ImportExport \Model \Import::IMPORT_DIR . $ fileName )
552
572
->willReturn ($ sourceFileRelativeNew );
553
- $ this ->_varDirectory
554
- ->expects ($ this ->once ())
555
- ->method ('copyFile ' )
556
- ->with (
557
- $ sourceFileRelativeNew ,
558
- $ copyFile
559
- );
560
573
$ this ->dateTime
561
574
->expects ($ this ->once ())
562
575
->method ('gmtTimestamp ' )
@@ -590,7 +603,6 @@ public function testCreateHistoryReportSourceFileRelativeIsNotArrayResultIsSet()
590
603
$ fileName = $ result ['name ' ];
591
604
$ gmtTimestamp = 1234567 ;
592
605
$ copyName = $ gmtTimestamp . '_ ' . $ fileName ;
593
- $ copyFile = \Magento \ImportExport \Model \Import::IMPORT_HISTORY_DIR . $ copyName ;
594
606
595
607
$ this ->import
596
608
->expects ($ this ->once ())
@@ -600,13 +612,6 @@ public function testCreateHistoryReportSourceFileRelativeIsNotArrayResultIsSet()
600
612
$ this ->_varDirectory
601
613
->expects ($ this ->never ())
602
614
->method ('getRelativePath ' );
603
- $ this ->_varDirectory
604
- ->expects ($ this ->once ())
605
- ->method ('copyFile ' )
606
- ->with (
607
- $ sourceFileRelative ,
608
- $ copyFile
609
- );
610
615
$ this ->dateTime
611
616
->expects ($ this ->once ())
612
617
->method ('gmtTimestamp ' )
@@ -638,7 +643,6 @@ public function testCreateHistoryReportExtensionIsSet()
638
643
$ fileName = $ entity . $ extension ;
639
644
$ gmtTimestamp = 1234567 ;
640
645
$ copyName = $ gmtTimestamp . '_ ' . $ fileName ;
641
- $ copyFile = \Magento \ImportExport \Model \Import::IMPORT_HISTORY_DIR . $ copyName ;
642
646
643
647
$ this ->import
644
648
->expects ($ this ->once ())
@@ -648,13 +652,6 @@ public function testCreateHistoryReportExtensionIsSet()
648
652
$ this ->_varDirectory
649
653
->expects ($ this ->never ())
650
654
->method ('getRelativePath ' );
651
- $ this ->_varDirectory
652
- ->expects ($ this ->once ())
653
- ->method ('copyFile ' )
654
- ->with (
655
- $ sourceFileRelative ,
656
- $ copyFile
657
- );
658
655
$ this ->dateTime
659
656
->expects ($ this ->once ())
660
657
->method ('gmtTimestamp ' )
@@ -697,20 +694,16 @@ public function testCreateHistoryReportThrowException()
697
694
->expects ($ this ->never ())
698
695
->method ('getRelativePath ' );
699
696
$ 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 ' )
703
700
->willReturnCallback (function () use ($ phrase ) {
704
701
throw new \Magento \Framework \Exception \FileSystemException ($ phrase );
705
702
});
706
703
$ this ->dateTime
707
704
->expects ($ this ->once ())
708
705
->method ('gmtTimestamp ' )
709
706
->willReturn ($ gmtTimestamp );
710
- $ this ->historyModel
711
- ->expects ($ this ->never ())
712
- ->method ('addReport ' );
713
-
714
707
$ args = [
715
708
$ sourceFileRelative ,
716
709
$ entity ,
0 commit comments