55
66use ArrayIterator ;
77use Exception ;
8+ use FD \LogViewer \Entity \Index \LogRecord ;
89use FD \LogViewer \Entity \Index \LogRecordCollection ;
910use FD \LogViewer \Entity \Index \PerformanceStats ;
1011use FD \LogViewer \Entity \Output \LogRecordsOutput ;
1112use FD \LogViewer \Entity \Request \LogQueryDto ;
12- use FD \LogViewer \Iterator \DeduplicationIterator ;
13- use FD \LogViewer \Iterator \LimitIterator ;
14- use FD \LogViewer \Iterator \MultiLogRecordIterator ;
1513use FD \LogViewer \Service \File \LogFileParserInterface ;
1614use FD \LogViewer \Service \File \LogFileParserProvider ;
17- use FD \LogViewer \Service \File \LogRecordDateComparator ;
1815use FD \LogViewer \Service \File \LogRecordsOutputProvider ;
1916use FD \LogViewer \Service \PerformanceService ;
2017use FD \LogViewer \Tests \Utility \TestEntityTrait ;
@@ -46,13 +43,16 @@ public function testProvide(): void
4643 $ logQuery = new LogQueryDto (['identifier ' ]);
4744 $ file = $ this ->createLogFile ();
4845 $ config = $ file ->folder ->collection ->config ;
46+ $ record = new LogRecord ('id ' , 111111 , 'debug ' , 'request ' , 'message ' , [], []);
4947 $ recordCollection = $ this ->createMock (LogRecordCollection::class);
50- $ performance = new PerformanceStats ('1 ' , '2 ' , '3 ' );
48+ $ recordCollection ->method ('getRecords ' )->willReturn ([$ record ]);
49+ $ recordCollection ->method ('getPaginator ' )->willReturn (null );
50+ $ performance = new PerformanceStats ('1 ' , '2 ' , '3 ' );
5151
5252 $ this ->logParser ->expects (self ::once ())->method ('getLogIndex ' )->with ($ config , $ file , $ logQuery )->willReturn ($ recordCollection );
5353 $ this ->performanceService ->expects (self ::once ())->method ('getPerformanceStats ' )->willReturn ($ performance );
5454
55- $ expected = new LogRecordsOutput ($ recordCollection , $ performance );
55+ $ expected = new LogRecordsOutput ([ $ record ], null , $ performance );
5656
5757 $ result = $ this ->provider ->provide ($ file , $ logQuery );
5858 static ::assertEquals ($ expected , $ result );
@@ -66,24 +66,16 @@ public function testProvideForFiles(): void
6666 $ logQuery = new LogQueryDto (['identifier ' ]);
6767 $ file = $ this ->createLogFile ();
6868 $ config = $ file ->folder ->collection ->config ;
69+ $ record = new LogRecord ('id ' , 111111 , 'debug ' , 'request ' , 'message ' , [], []);
6970 $ recordCollection = $ this ->createMock (LogRecordCollection::class);
70- $ iterator = new ArrayIterator ([]);
71- $ performance = new PerformanceStats ('1 ' , '2 ' , '3 ' );
71+ $ recordCollection ->method ('getIterator ' )->willReturn (new ArrayIterator ([$ record ]));
72+ $ recordCollection ->method ('getPaginator ' )->willReturn (null );
73+ $ performance = new PerformanceStats ('1 ' , '2 ' , '3 ' );
7274
7375 $ this ->logParser ->expects (self ::once ())->method ('getLogIndex ' )->with ($ config , $ file , $ logQuery )->willReturn ($ recordCollection );
74- $ recordCollection ->expects (self ::once ())->method ('getIterator ' )->willReturn ($ iterator );
7576 $ this ->performanceService ->expects (self ::once ())->method ('getPerformanceStats ' )->willReturn ($ performance );
7677
77- $ expected = new LogRecordsOutput (
78- new LogRecordCollection (
79- new LimitIterator (
80- new DeduplicationIterator (new MultiLogRecordIterator ([$ iterator ], new LogRecordDateComparator ($ logQuery ->direction ))),
81- $ logQuery ->perPage
82- ),
83- null
84- ),
85- $ performance
86- );
78+ $ expected = new LogRecordsOutput ([$ record ], null , $ performance );
8779
8880 $ result = $ this ->provider ->provideForFiles (['foo ' => $ file ], $ logQuery );
8981 static ::assertEquals ($ expected , $ result );
0 commit comments