protected function setUpFileMonitorForDetection(array $changeDetectionResult, array $expectedEmittedChanges, array $knownDirectoriesAndFiles)
{
$mockChangeDetectionStrategy = $this->createMock(ChangeDetectionStrategyInterface::class);
$mockChangeDetectionStrategy->expects($this->any())->method('getFileStatus')->will($this->returnCallback(function ($pathAndFilename) use($changeDetectionResult) {
if (isset($changeDetectionResult[$pathAndFilename])) {
return $changeDetectionResult[$pathAndFilename];
} else {
return ChangeDetectionStrategyInterface::STATUS_UNCHANGED;
}
}));
$fileMonitor = $this->getAccessibleMock(FileMonitor::class, ['emitFilesHaveChanged', 'emitDirectoriesHaveChanged'], ['Flow_Test'], '', true, true);
$this->inject($fileMonitor, 'changeDetectionStrategy', $mockChangeDetectionStrategy);
$fileMonitor->expects($this->once())->method('emitFilesHaveChanged')->with('Flow_Test', $expectedEmittedChanges);
$mockSystemLogger = $this->createMock(SystemLoggerInterface::class);
$fileMonitor->injectSystemLogger($mockSystemLogger);
$mockCache = $this->getMockBuilder(Cache\Frontend\StringFrontend::class)->disableOriginalConstructor()->getMock();
$mockCache->expects($this->once())->method('get')->will($this->returnValue(json_encode($knownDirectoriesAndFiles)));
$fileMonitor->injectCache($mockCache);
return $fileMonitor;
}