/**
  * Cover createHistoryReport().
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Source file coping failed
  */
 public function testCreateHistoryReportThrowException()
 {
     $sourceFileRelative = null;
     $entity = '';
     $extension = '';
     $result = '';
     $gmtTimestamp = 1234567;
     $this->import->expects($this->once())->method('isReportEntityType')->with($entity)->willReturn(true);
     $this->_varDirectory->expects($this->never())->method('getRelativePath');
     $phrase = $this->getMock('\\Magento\\Framework\\Phrase', [], [], '', false);
     $this->_driver->expects($this->any())->method('fileGetContents')->willReturnCallback(function () use($phrase) {
         throw new \Magento\Framework\Exception\FileSystemException($phrase);
     });
     $this->dateTime->expects($this->once())->method('gmtTimestamp')->willReturn($gmtTimestamp);
     $args = [$sourceFileRelative, $entity, $extension, $result];
     $actualResult = $this->invokeMethod($this->import, 'createHistoryReport', $args);
     $this->assertEquals($this->import, $actualResult);
 }
Exemple #2
0
 public function testImportSource()
 {
     $entityTypeCode = 'code';
     $this->_importData->expects($this->any())->method('getEntityTypeCode')->will($this->returnValue($entityTypeCode));
     $behaviour = 'behaviour';
     $this->_importData->expects($this->once())->method('getBehavior')->will($this->returnValue($behaviour));
     $this->import->expects($this->any())->method('getDataSourceModel')->will($this->returnValue($this->_importData));
     $this->import->expects($this->any())->method('setData')->withConsecutive(['entity', $entityTypeCode], ['behavior', $behaviour]);
     $phraseClass = '\\Magento\\Framework\\Phrase';
     $this->import->expects($this->any())->method('addLogComment')->with($this->isInstanceOf($phraseClass));
     $this->_entityAdapter->expects($this->once())->method('importData')->will($this->returnSelf());
     $this->import->expects($this->once())->method('_getEntityAdapter')->will($this->returnValue($this->_entityAdapter));
     $importOnceMethodsReturnNull = ['getEntity', 'getBehavior', 'getProcessedRowsCount', 'getProcessedEntitiesCount', 'getInvalidRowsCount', 'getErrorsCount'];
     foreach ($importOnceMethodsReturnNull as $method) {
         $this->import->expects($this->once())->method($method)->will($this->returnValue(null));
     }
     $this->import->importSource();
 }
 protected function processBehaviorGetter($behavior)
 {
     $dataSource = $this->getMock('Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data', [], [], '', false);
     $dataSource->expects($this->once())->method('getBehavior')->will($this->returnValue($behavior));
     $this->import->expects($this->once())->method('getDataSourceModel')->will($this->returnValue($dataSource));
 }