File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -191,4 +191,43 @@ private function getTestStorage($scan = true) {
191191 $ this ->storages [] = $ storage ;
192192 return $ storage ;
193193 }
194+
195+ public static function checkFilterProvider (): array {
196+ return [
197+ [null , [
198+ '' => true ,
199+ 'foo ' => true ,
200+ 'foo.txt ' => true ,
201+ ]],
202+ ['/^.+$/ ' , [
203+ '' => false ,
204+ 'foo ' => true ,
205+ 'foo.txt ' => true ,
206+ ]],
207+ ['/^.+\..+$/ ' , [
208+ '' => false ,
209+ 'foo ' => false ,
210+ 'foo.txt ' => true ,
211+ ]]
212+ ];
213+ }
214+
215+ #[DataProvider('checkFilterProvider ' )]
216+ public function testCheckFilter ($ filter , $ paths ) {
217+ $ storage = $ this ->createMock (IStorage::class);
218+ $ storage ->method ('hasUpdated ' )
219+ ->willReturn (true );
220+ $ watcher = new Watcher ($ storage );
221+ $ watcher ->setPolicy (IWatcher::CHECK_ALWAYS );
222+
223+ $ watcher ->setCheckFilter ($ filter );
224+
225+ $ entry = new CacheEntry ([
226+ 'storage_mtime ' => 0 ,
227+ ]);
228+
229+ foreach ($ paths as $ patch => $ shouldUpdate ) {
230+ $ this ->assertEquals ($ shouldUpdate , $ watcher ->needsUpdate ($ patch , $ entry ));
231+ }
232+ }
194233}
You can’t perform that action at this time.
0 commit comments