@@ -749,6 +749,60 @@ public function testSetsFileVersionsLabelIfKeepOriginalFileVersionIsTrue() {
749749 $ this ->ocrService ->runOcrProcess (42 , 'usr ' , $ settings );
750750 }
751751
752+ // Related to #307
753+ public function testRunOcrProcessWorksWithoutIVersionManager () {
754+ $ settings = new WorkflowSettings ('{"keepOriginalFileVersion": true} ' );
755+ $ mimeType = 'application/pdf ' ;
756+ $ content = 'someFileContent ' ;
757+ $ ocrContent = 'someOcrProcessedFile ' ;
758+ $ ocrResult = new OcrProcessorResult ($ ocrContent , 'pdf ' , $ ocrContent );
759+
760+ $ fileMock = $ this ->createValidFileMock ($ mimeType , $ content );
761+ $ this ->rootFolderGetById42ReturnValue = [$ fileMock ];
762+
763+ $ this ->ocrProcessor ->expects ($ this ->once ())
764+ ->method ('ocrFile ' )
765+ ->willReturn ($ ocrResult );
766+
767+ $ viewMock = $ this ->createMock (IView::class);
768+ $ this ->viewFactory ->expects ($ this ->once ())
769+ ->method ('create ' )
770+ ->willReturn ($ viewMock );
771+
772+ $ this ->eventService ->expects ($ this ->once ())
773+ ->method ('textRecognized ' )
774+ ->with ($ ocrResult , $ fileMock );
775+
776+ $ logged = false ;
777+ $ this ->logger ->expects ($ this ->atLeast (1 ))
778+ ->method ('debug ' )
779+ ->with ($ this ->callback (function ($ message ) use (&$ logged ) {
780+ if ($ message === 'Skipping setting file version label because file version app is not active ' ) {
781+ $ logged = true ;
782+ }
783+ return true ;
784+ }));
785+
786+ $ ocrService = new OcrService (
787+ $ this ->ocrProcessorFactory ,
788+ $ this ->globalSettingsService ,
789+ null , // No IVersionManager
790+ $ this ->systemTagObjectMapper ,
791+ $ this ->userManager ,
792+ $ this ->filesystem ,
793+ $ this ->userSession ,
794+ $ this ->rootFolder ,
795+ $ this ->eventService ,
796+ $ this ->viewFactory ,
797+ $ this ->processingFileAccessor ,
798+ $ this ->notificationService ,
799+ $ this ->logger );
800+
801+ $ ocrService ->runOcrProcess (42 , 'usr ' , $ settings );
802+
803+ $ this ->assertTrue ($ logged , 'Expected debug log message not found ' );
804+ }
805+
752806 public static function dataProvider_InvalidNodes () {
753807 $ folderMockCallable = function (self $ testClass ) {
754808 /** @var MockObject|Node */
0 commit comments