88use  DR \Review \Entity \Git \Diff \DiffFile ;
99use  DR \Review \Entity \Git \Diff \DiffLine ;
1010use  DR \Review \Service \CodeHighlight \FilenameToLanguageTranslator ;
11+ use  DR \Review \Service \CodeHighlight \HighlightedFilePreprocessor ;
1112use  DR \Review \Service \CodeHighlight \HighlightedFileService ;
1213use  DR \Review \Service \CodeHighlight \HighlightHtmlLineSplitter ;
1314use  DR \Review \Tests \AbstractTestCase ;
@@ -25,15 +26,17 @@ class HighlightedFileServiceTest extends AbstractTestCase
2526    private  FilenameToLanguageTranslator MockObject $ translator
2627    private  HttpClientInterface MockObject $ httpClient
2728    private  HighlightHtmlLineSplitter MockObject $ splitter
29+     private  HighlightedFilePreprocessor MockObject $ preprocessor
2830    private  HighlightedFileService $ service
2931
3032    public  function  setUp (): void 
3133    {
3234        parent ::setUp ();
33-         $ this translator  = $ this createMock (FilenameToLanguageTranslator::class);
34-         $ this httpClient  = $ this createMock (HttpClientInterface::class);
35-         $ this splitter    = $ this createMock (HighlightHtmlLineSplitter::class);
36-         $ this service     = new  HighlightedFileService ($ this translator , $ this httpClient , $ this splitter );
35+         $ this translator    = $ this createMock (FilenameToLanguageTranslator::class);
36+         $ this httpClient    = $ this createMock (HttpClientInterface::class);
37+         $ this splitter      = $ this createMock (HighlightHtmlLineSplitter::class);
38+         $ this preprocessor  = $ this createMock (HighlightedFilePreprocessor::class);
39+         $ this service       = new  HighlightedFileService ($ this translator , $ this httpClient , $ this splitter , $ this preprocessor );
3740    }
3841
3942    /** 
@@ -73,6 +76,7 @@ public function testGetHighlightedFile(): void
7376            ->with ('POST ' , '' , ['query '  => ['language '  => 'xml ' ], 'body '  => 'file-data ' ])
7477            ->willReturn ($ response
7578        $ this splitter ->expects ($ this once ())->method ('split ' )->with ('highlighted-data ' )->willReturn (['highlighted ' , 'data ' ]);
79+         $ this preprocessor ->expects ($ this once ())->method ('process ' )->with ('xml ' , 'file-data ' )->willReturnArgument (1 );
7680
7781        $ actual$ this service ->fromDiffFile ($ file
7882        static ::assertNotNull ($ actual
@@ -92,6 +96,7 @@ public function testGetHighlightedFileRequestFailure(): void
9296        $ fileaddBlock ($ block
9397
9498        $ this translator ->expects ($ this once ())->method ('translate ' )->with ('/path/to/file.xml ' )->willReturn ('xml ' );
99+         $ this preprocessor ->expects ($ this once ())->method ('process ' )->with ('xml ' , 'file-data ' )->willReturnArgument (1 );
95100        $ this httpClient ->expects ($ this once ())->method ('request ' )->willThrowException (new  RuntimeException ('error ' ));
96101
97102        static ::assertNull ($ this service ->fromDiffFile ($ file
0 commit comments