getMockBuilder(CsvExporter::class) ->disableOriginalConstructor() ->getMock(); $exportHandler = $this->getMockBuilder(ExportHandler::class) ->disableOriginalConstructor() ->getMock(); $handler = 'Handler'; $report = new Report(); $report->setName('Report A'); $scheduler = new Scheduler($report, new \DateTime()); $reportDataResult = new ReportDataResult(Fixtures::getValidReportResult()); $coreParametersHelper = $this->getMockBuilder(CoreParametersHelper::class) ->disableOriginalConstructor() ->getMock(); $coreParametersHelper->expects($this->once()) ->method('get') ->with('report_export_batch_size') ->willReturn(3); $reportExportOptions = new ReportExportOptions($coreParametersHelper); $exportHandler->expects($this->once()) ->method('getHandler') ->willReturn($handler); $csvExporter->expects($this->once()) ->method('export') ->with($reportDataResult, $handler, 1); $exportHandler->expects($this->once()) ->method('closeHandler'); $reportFileWriter = new ReportFileWriter($csvExporter, $exportHandler); $reportFileWriter->writeReportData($scheduler, $reportDataResult, $reportExportOptions); } public function testClear(): void { $csvExporter = $this->getMockBuilder(CsvExporter::class) ->disableOriginalConstructor() ->getMock(); $exportHandler = $this->getMockBuilder(ExportHandler::class) ->disableOriginalConstructor() ->getMock(); $report = new Report(); $scheduler = new Scheduler($report, new \DateTime()); $report->setName('Report A'); $exportHandler->expects($this->once()) ->method('removeFile'); $reportFileWriter = new ReportFileWriter($csvExporter, $exportHandler); $reportFileWriter->clear($scheduler); } public function testGetFilePath(): void { $csvExporter = $this->getMockBuilder(CsvExporter::class) ->disableOriginalConstructor() ->getMock(); $exportHandler = $this->getMockBuilder(ExportHandler::class) ->disableOriginalConstructor() ->getMock(); $report = new Report(); $scheduler = new Scheduler($report, new \DateTime()); $report->setName('Report A'); $exportHandler->expects($this->once()) ->method('getPath'); $reportFileWriter = new ReportFileWriter($csvExporter, $exportHandler); $reportFileWriter->getFilePath($scheduler); } }