/** * Test getExecutionTime() */ public function testGetSummaryStats() { $logger = $this->getMock('Psr\\Log\\LoggerInterface', [], [], '', false); $filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false); $importExportData = $this->getMock('Magento\\ImportExport\\Helper\\Data', [], [], '', false); $coreConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], [], '', false); $importConfig = $this->getMock('Magento\\ImportExport\\Model\\Import\\Config', ['getEntities'], [], '', false); $importConfig->expects($this->any())->method('getEntities')->willReturn(['catalog_product' => ['model' => 'catalog_product']]); $entityFactory = $this->getMock('Magento\\ImportExport\\Model\\Import\\Entity\\Factory', ['create'], [], '', false); $product = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getEntityTypeCode', 'setParameters'], [], '', false); $product->expects($this->any())->method('getEntityTypeCode')->willReturn('catalog_product'); $product->expects($this->any())->method('setParameters')->willReturn(''); $entityFactory->expects($this->any())->method('create')->willReturn($product); $importData = $this->getMock('Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data', [], [], '', false); $csvFactory = $this->getMock('Magento\\ImportExport\\Model\\Export\\Adapter\\CsvFactory', [], [], '', false); $httpFactory = $this->getMock('Magento\\Framework\\HTTP\\Adapter\\FileTransferFactory', [], [], '', false); $uploaderFactory = $this->getMock('Magento\\MediaStorage\\Model\\File\\UploaderFactory', [], [], '', false); $behaviorFactory = $this->getMock('Magento\\ImportExport\\Model\\Source\\Import\\Behavior\\Factory', [], [], '', false); $indexerRegistry = $this->getMock('Magento\\Framework\\Indexer\\IndexerRegistry', [], [], '', false); $importHistoryModel = $this->getMock('Magento\\ImportExport\\Model\\History', [], [], '', false); $localeDate = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateTime', [], [], '', false); $import = new \Magento\ImportExport\Model\Import($logger, $filesystem, $importExportData, $coreConfig, $importConfig, $entityFactory, $importData, $csvFactory, $httpFactory, $uploaderFactory, $behaviorFactory, $indexerRegistry, $importHistoryModel, $localeDate); $import->setData('entity', 'catalog_product'); $message = $this->report->getSummaryStats($import); $this->assertInstanceOf('Magento\\Framework\\Phrase', $message); }
/** * Update import history report * * @param Import $import * @param bool $updateSummary * @return $this */ public function updateReport(Import $import, $updateSummary = false) { if ($import->isReportEntityType()) { $this->load($this->getLastItemId()); $executionResult = self::IMPORT_IN_PROCESS; if ($updateSummary) { $executionResult = $this->reportHelper->getExecutionTime($this->getStartedAt()); $summary = $this->reportHelper->getSummaryStats($import); $this->setSummary($summary); } $this->setExecutionTime($executionResult); $this->save(); } return $this; }