public function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->reportHelperMock = $this->getMock('\\Magento\\ImportExport\\Helper\\Report', [], [], '', false); $this->outputCsvFactoryMock = $this->getMock('\\Magento\\ImportExport\\Model\\Export\\Adapter\\CsvFactory', ['create'], [], '', false); $this->outputCsvMock = $this->getMock('\\Magento\\ImportExport\\Model\\Export\\Adapter\\Csv', [], [], '', false); $this->outputCsvFactoryMock->expects($this->any())->method('create')->willReturn($this->outputCsvMock); $this->sourceCsvFactoryMock = $this->getMock('\\Magento\\ImportExport\\Model\\Import\\Source\\CsvFactory', ['create'], [], '', false); $this->sourceCsvMock = $this->getMock('\\Magento\\ImportExport\\Model\\Import\\Source\\Csv', [], [], '', false); $this->sourceCsvMock->expects($this->any())->method('valid')->willReturnOnConsecutiveCalls(true, true, false); $this->sourceCsvMock->expects($this->any())->method('current')->willReturnOnConsecutiveCalls([23 => 'first error'], [27 => 'second error']); $this->sourceCsvFactoryMock->expects($this->any())->method('create')->willReturn($this->sourceCsvMock); $this->filesystemMock = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false); $this->csvModel = $objectManager->getObject('\\Magento\\ImportExport\\Model\\Report\\Csv', ['reportHelper' => $this->reportHelperMock, 'sourceCsvFactory' => $this->sourceCsvFactoryMock, 'outputCsvFactory' => $this->outputCsvFactoryMock, 'filesystem' => $this->filesystemMock]); }
/** * @param string $outputFileName * @return \Magento\ImportExport\Model\Export\Adapter\Csv */ protected function createOutputCsvModel($outputFileName) { return $this->outputCsvFactory->create(['destination' => Import::IMPORT_HISTORY_DIR . $outputFileName, 'destinationDirectoryCode' => DirectoryList::VAR_DIR]); }