|
11 | 11 | use OC\Files\Cache\Wrapper\CacheJail; |
12 | 12 | use OC\Files\Search\SearchComparison; |
13 | 13 | use OC\Files\Search\SearchQuery; |
| 14 | +use OC\Files\Storage\Wrapper\Jail; |
14 | 15 | use OC\User\User; |
15 | 16 | use OCP\EventDispatcher\IEventDispatcher; |
16 | 17 | use OCP\Files\Search\ISearchComparison; |
@@ -218,4 +219,33 @@ public function testRootJail() { |
218 | 219 | $this->assertCount(1, $result); |
219 | 220 | $this->assertEquals('foo/bar/asd', $result[0]['path']); |
220 | 221 | } |
| 222 | + |
| 223 | + public function testWatcher() { |
| 224 | + $storage = new Jail([ |
| 225 | + 'storage' => $this->storage, |
| 226 | + 'root' => 'foo' |
| 227 | + ]); |
| 228 | + $storage->getScanner()->scan(''); |
| 229 | + $storage->file_put_contents('bar', 'asd'); |
| 230 | + |
| 231 | + $this->assertFalse($this->cache->inCache('bar')); |
| 232 | + $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']); |
| 233 | + $this->assertTrue($this->cache->inCache('bar')); |
| 234 | + } |
| 235 | + |
| 236 | + public function testWatcherAfterInnerWatcher() { |
| 237 | + $storage = new Jail([ |
| 238 | + 'storage' => $this->storage, |
| 239 | + 'root' => 'foo' |
| 240 | + ]); |
| 241 | + $storage->getScanner()->scan(''); |
| 242 | + $storage->file_put_contents('bar', 'asd'); |
| 243 | + |
| 244 | + // let the underlying storage create it's watcher first |
| 245 | + $this->storage->getWatcher(); |
| 246 | + |
| 247 | + $this->assertFalse($this->cache->inCache('bar')); |
| 248 | + $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']); |
| 249 | + $this->assertTrue($this->cache->inCache('bar')); |
| 250 | + } |
221 | 251 | } |
0 commit comments