Skip to content

Commit 5978d4d

Browse files
icewind1991backportbot[bot]
authored andcommitted
test: add tests for watcher check filter
Signed-off-by: Robin Appelman <[email protected]> [skip ci]
1 parent 001e28c commit 5978d4d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/lib/Files/Cache/WatcherTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)