File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 77
88namespace Test \Files \Cache ;
99
10+ use OC \Files \Cache \CacheEntry ;
11+ use OC \Files \Cache \Watcher ;
12+ use OCP \Files \Cache \IWatcher ;
13+ use OCP \Files \Storage \IStorage ;
14+ use PHPUnit \Framework \Attributes \DataProvider ;
15+
1016/**
1117 * Class WatcherTest
1218 *
@@ -191,4 +197,43 @@ private function getTestStorage($scan = true) {
191197 $ this ->storages [] = $ storage ;
192198 return $ storage ;
193199 }
200+
201+ public static function checkFilterProvider (): array {
202+ return [
203+ [null , [
204+ '' => true ,
205+ 'foo ' => true ,
206+ 'foo.txt ' => true ,
207+ ]],
208+ ['/^.+$/ ' , [
209+ '' => false ,
210+ 'foo ' => true ,
211+ 'foo.txt ' => true ,
212+ ]],
213+ ['/^.+\..+$/ ' , [
214+ '' => false ,
215+ 'foo ' => false ,
216+ 'foo.txt ' => true ,
217+ ]]
218+ ];
219+ }
220+
221+ #[DataProvider('checkFilterProvider ' )]
222+ public function testCheckFilter ($ filter , $ paths ) {
223+ $ storage = $ this ->createMock (IStorage::class);
224+ $ storage ->method ('hasUpdated ' )
225+ ->willReturn (true );
226+ $ watcher = new Watcher ($ storage );
227+ $ watcher ->setPolicy (IWatcher::CHECK_ALWAYS );
228+
229+ $ watcher ->setCheckFilter ($ filter );
230+
231+ $ entry = new CacheEntry ([
232+ 'storage_mtime ' => 0 ,
233+ ]);
234+
235+ foreach ($ paths as $ patch => $ shouldUpdate ) {
236+ $ this ->assertEquals ($ shouldUpdate , $ watcher ->needsUpdate ($ patch , $ entry ));
237+ }
238+ }
194239}
You can’t perform that action at this time.
0 commit comments