File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-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,45 @@ 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+ /**
222+ * @dataProvider checkFilterProvider
223+ */
224+ public function testCheckFilter ($ filter , $ paths ) {
225+ $ storage = $ this ->createMock (IStorage::class);
226+ $ storage ->method ('hasUpdated ' )
227+ ->willReturn (true );
228+ $ watcher = new Watcher ($ storage );
229+ $ watcher ->setPolicy (IWatcher::CHECK_ALWAYS );
230+
231+ $ watcher ->setCheckFilter ($ filter );
232+
233+ $ entry = new CacheEntry ([
234+ 'storage_mtime ' => 0 ,
235+ ]);
236+
237+ foreach ($ paths as $ patch => $ shouldUpdate ) {
238+ $ this ->assertEquals ($ shouldUpdate , $ watcher ->needsUpdate ($ patch , $ entry ));
239+ }
240+ }
194241}
You can’t perform that action at this time.
0 commit comments