@@ -13,123 +13,123 @@ |
||
| 13 | 13 | use OCP\Files\FileInfo; |
| 14 | 14 | |
| 15 | 15 | class NulLCacheTest extends \Test\TestCase { |
| 16 | - /** @var NullCache */ |
|
| 17 | - private $cache; |
|
| 16 | + /** @var NullCache */ |
|
| 17 | + private $cache; |
|
| 18 | 18 | |
| 19 | - protected function setUp(): void { |
|
| 20 | - parent::setUp(); |
|
| 19 | + protected function setUp(): void { |
|
| 20 | + parent::setUp(); |
|
| 21 | 21 | |
| 22 | - $this->cache = new NullCache(); |
|
| 23 | - } |
|
| 22 | + $this->cache = new NullCache(); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function testGetNumericStorageId(): void { |
|
| 26 | - $this->assertSame(-1, $this->cache->getNumericStorageId()); |
|
| 27 | - } |
|
| 25 | + public function testGetNumericStorageId(): void { |
|
| 26 | + $this->assertSame(-1, $this->cache->getNumericStorageId()); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function testGetEmpty(): void { |
|
| 30 | - $this->assertFalse($this->cache->get('foo')); |
|
| 31 | - } |
|
| 29 | + public function testGetEmpty(): void { |
|
| 30 | + $this->assertFalse($this->cache->get('foo')); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function testGet(): void { |
|
| 34 | - $data = $this->cache->get(''); |
|
| 33 | + public function testGet(): void { |
|
| 34 | + $data = $this->cache->get(''); |
|
| 35 | 35 | |
| 36 | - $this->assertEquals(-1, $data['fileid']); |
|
| 37 | - $this->assertEquals(-1, $data['parent']); |
|
| 38 | - $this->assertEquals('', $data['name']); |
|
| 39 | - $this->assertEquals('', $data['path']); |
|
| 40 | - $this->assertEquals('0', $data['size']); |
|
| 41 | - $this->assertEquals('', $data['etag']); |
|
| 42 | - $this->assertEquals(FileInfo::MIMETYPE_FOLDER, $data['mimetype']); |
|
| 43 | - $this->assertEquals('httpd', $data['mimepart']); |
|
| 44 | - $this->assertEquals(Constants::PERMISSION_READ, $data['permissions']); |
|
| 45 | - } |
|
| 36 | + $this->assertEquals(-1, $data['fileid']); |
|
| 37 | + $this->assertEquals(-1, $data['parent']); |
|
| 38 | + $this->assertEquals('', $data['name']); |
|
| 39 | + $this->assertEquals('', $data['path']); |
|
| 40 | + $this->assertEquals('0', $data['size']); |
|
| 41 | + $this->assertEquals('', $data['etag']); |
|
| 42 | + $this->assertEquals(FileInfo::MIMETYPE_FOLDER, $data['mimetype']); |
|
| 43 | + $this->assertEquals('httpd', $data['mimepart']); |
|
| 44 | + $this->assertEquals(Constants::PERMISSION_READ, $data['permissions']); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function testGetFolderContents(): void { |
|
| 48 | - $this->assertSame([], $this->cache->getFolderContents('foo')); |
|
| 49 | - } |
|
| 47 | + public function testGetFolderContents(): void { |
|
| 48 | + $this->assertSame([], $this->cache->getFolderContents('foo')); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function testGetFolderContentsById(): void { |
|
| 52 | - $this->assertSame([], $this->cache->getFolderContentsById(42)); |
|
| 53 | - } |
|
| 51 | + public function testGetFolderContentsById(): void { |
|
| 52 | + $this->assertSame([], $this->cache->getFolderContentsById(42)); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function testPut(): void { |
|
| 56 | - $this->expectException(ForbiddenException::class); |
|
| 57 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 55 | + public function testPut(): void { |
|
| 56 | + $this->expectException(ForbiddenException::class); |
|
| 57 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 58 | 58 | |
| 59 | - $this->cache->put('foo', ['size' => 100]); |
|
| 60 | - } |
|
| 59 | + $this->cache->put('foo', ['size' => 100]); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function testInsert(): void { |
|
| 63 | - $this->expectException(ForbiddenException::class); |
|
| 64 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 62 | + public function testInsert(): void { |
|
| 63 | + $this->expectException(ForbiddenException::class); |
|
| 64 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 65 | 65 | |
| 66 | - $this->cache->insert('foo', ['size' => 100]); |
|
| 67 | - } |
|
| 66 | + $this->cache->insert('foo', ['size' => 100]); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function testUpdate(): void { |
|
| 70 | - $this->expectException(ForbiddenException::class); |
|
| 71 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 69 | + public function testUpdate(): void { |
|
| 70 | + $this->expectException(ForbiddenException::class); |
|
| 71 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 72 | 72 | |
| 73 | - $this->cache->update('foo', ['size' => 100]); |
|
| 74 | - } |
|
| 73 | + $this->cache->update('foo', ['size' => 100]); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function testGetId(): void { |
|
| 77 | - $this->assertSame(-1, $this->cache->getId('foo')); |
|
| 78 | - } |
|
| 76 | + public function testGetId(): void { |
|
| 77 | + $this->assertSame(-1, $this->cache->getId('foo')); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public function testGetParentId(): void { |
|
| 81 | - $this->assertSame(-1, $this->cache->getParentId('foo')); |
|
| 82 | - } |
|
| 80 | + public function testGetParentId(): void { |
|
| 81 | + $this->assertSame(-1, $this->cache->getParentId('foo')); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - public function testInCache(): void { |
|
| 85 | - $this->assertTrue($this->cache->inCache('')); |
|
| 86 | - $this->assertFalse($this->cache->inCache('foo')); |
|
| 87 | - } |
|
| 84 | + public function testInCache(): void { |
|
| 85 | + $this->assertTrue($this->cache->inCache('')); |
|
| 86 | + $this->assertFalse($this->cache->inCache('foo')); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public function testRemove(): void { |
|
| 90 | - $this->expectException(ForbiddenException::class); |
|
| 91 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 89 | + public function testRemove(): void { |
|
| 90 | + $this->expectException(ForbiddenException::class); |
|
| 91 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 92 | 92 | |
| 93 | - $this->cache->remove('foo'); |
|
| 94 | - } |
|
| 93 | + $this->cache->remove('foo'); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - public function testMove(): void { |
|
| 97 | - $this->expectException(ForbiddenException::class); |
|
| 98 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 96 | + public function testMove(): void { |
|
| 97 | + $this->expectException(ForbiddenException::class); |
|
| 98 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 99 | 99 | |
| 100 | - $this->cache->move('foo', 'bar'); |
|
| 101 | - } |
|
| 100 | + $this->cache->move('foo', 'bar'); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - public function testMoveFromCache(): void { |
|
| 104 | - $sourceCache = $this->createMock(ICache::class); |
|
| 103 | + public function testMoveFromCache(): void { |
|
| 104 | + $sourceCache = $this->createMock(ICache::class); |
|
| 105 | 105 | |
| 106 | - $this->expectException(ForbiddenException::class); |
|
| 107 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 106 | + $this->expectException(ForbiddenException::class); |
|
| 107 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
| 108 | 108 | |
| 109 | - $this->cache->moveFromCache($sourceCache, 'foo', 'bar'); |
|
| 110 | - } |
|
| 109 | + $this->cache->moveFromCache($sourceCache, 'foo', 'bar'); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - public function testGetStatus(): void { |
|
| 113 | - $this->assertSame(ICache::COMPLETE, $this->cache->getStatus('foo')); |
|
| 114 | - } |
|
| 112 | + public function testGetStatus(): void { |
|
| 113 | + $this->assertSame(ICache::COMPLETE, $this->cache->getStatus('foo')); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - public function testSearch(): void { |
|
| 117 | - $this->assertSame([], $this->cache->search('foo')); |
|
| 118 | - } |
|
| 116 | + public function testSearch(): void { |
|
| 117 | + $this->assertSame([], $this->cache->search('foo')); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - public function testSearchByMime(): void { |
|
| 121 | - $this->assertSame([], $this->cache->searchByMime('foo')); |
|
| 122 | - } |
|
| 120 | + public function testSearchByMime(): void { |
|
| 121 | + $this->assertSame([], $this->cache->searchByMime('foo')); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public function testGetIncomplete(): void { |
|
| 125 | - $this->assertSame([], $this->cache->getIncomplete()); |
|
| 126 | - } |
|
| 124 | + public function testGetIncomplete(): void { |
|
| 125 | + $this->assertSame([], $this->cache->getIncomplete()); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - public function testGetPathById(): void { |
|
| 129 | - $this->assertSame('', $this->cache->getPathById(42)); |
|
| 130 | - } |
|
| 128 | + public function testGetPathById(): void { |
|
| 129 | + $this->assertSame('', $this->cache->getPathById(42)); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public function testNormalize(): void { |
|
| 133 | - $this->assertSame('foo/ bar /', $this->cache->normalize('foo/ bar /')); |
|
| 134 | - } |
|
| 132 | + public function testNormalize(): void { |
|
| 133 | + $this->assertSame('foo/ bar /', $this->cache->normalize('foo/ bar /')); |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -16,111 +16,111 @@ |
||
| 16 | 16 | use OCP\Files\Search\ISearchQuery; |
| 17 | 17 | |
| 18 | 18 | class NullCache implements ICache { |
| 19 | - public function getNumericStorageId() { |
|
| 20 | - return -1; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function get($file) { |
|
| 24 | - if ($file !== '') { |
|
| 25 | - return false; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - return new CacheEntry([ |
|
| 29 | - 'fileid' => -1, |
|
| 30 | - 'parent' => -1, |
|
| 31 | - 'name' => '', |
|
| 32 | - 'path' => '', |
|
| 33 | - 'size' => '0', |
|
| 34 | - 'mtime' => time(), |
|
| 35 | - 'storage_mtime' => time(), |
|
| 36 | - 'etag' => '', |
|
| 37 | - 'mimetype' => FileInfo::MIMETYPE_FOLDER, |
|
| 38 | - 'mimepart' => 'httpd', |
|
| 39 | - 'permissions' => Constants::PERMISSION_READ |
|
| 40 | - ]); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function getFolderContents($folder) { |
|
| 44 | - return []; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function getFolderContentsById($fileId) { |
|
| 48 | - return []; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function put($file, array $data) { |
|
| 52 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function insert($file, array $data) { |
|
| 56 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function update($id, array $data) { |
|
| 60 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function getId($file) { |
|
| 64 | - return -1; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - public function getParentId($file) { |
|
| 68 | - return -1; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function inCache($file) { |
|
| 72 | - return $file === ''; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - public function remove($file) { |
|
| 76 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function move($source, $target) { |
|
| 80 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
| 84 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function getStatus($file) { |
|
| 88 | - return ICache::COMPLETE; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - public function search($pattern) { |
|
| 92 | - return []; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function searchByMime($mimetype) { |
|
| 96 | - return []; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - public function searchQuery(ISearchQuery $query) { |
|
| 100 | - return []; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function getIncomplete() { |
|
| 104 | - return []; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function getPathById($id) { |
|
| 108 | - return ''; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function normalize($path) { |
|
| 112 | - return $path; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int { |
|
| 116 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function getQueryFilterForStorage(): ISearchOperator { |
|
| 120 | - return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', -1); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { |
|
| 124 | - return null; |
|
| 125 | - } |
|
| 19 | + public function getNumericStorageId() { |
|
| 20 | + return -1; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function get($file) { |
|
| 24 | + if ($file !== '') { |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + return new CacheEntry([ |
|
| 29 | + 'fileid' => -1, |
|
| 30 | + 'parent' => -1, |
|
| 31 | + 'name' => '', |
|
| 32 | + 'path' => '', |
|
| 33 | + 'size' => '0', |
|
| 34 | + 'mtime' => time(), |
|
| 35 | + 'storage_mtime' => time(), |
|
| 36 | + 'etag' => '', |
|
| 37 | + 'mimetype' => FileInfo::MIMETYPE_FOLDER, |
|
| 38 | + 'mimepart' => 'httpd', |
|
| 39 | + 'permissions' => Constants::PERMISSION_READ |
|
| 40 | + ]); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function getFolderContents($folder) { |
|
| 44 | + return []; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function getFolderContentsById($fileId) { |
|
| 48 | + return []; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function put($file, array $data) { |
|
| 52 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function insert($file, array $data) { |
|
| 56 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function update($id, array $data) { |
|
| 60 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function getId($file) { |
|
| 64 | + return -1; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + public function getParentId($file) { |
|
| 68 | + return -1; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function inCache($file) { |
|
| 72 | + return $file === ''; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + public function remove($file) { |
|
| 76 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function move($source, $target) { |
|
| 80 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
| 84 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function getStatus($file) { |
|
| 88 | + return ICache::COMPLETE; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + public function search($pattern) { |
|
| 92 | + return []; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function searchByMime($mimetype) { |
|
| 96 | + return []; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + public function searchQuery(ISearchQuery $query) { |
|
| 100 | + return []; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function getIncomplete() { |
|
| 104 | + return []; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function getPathById($id) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function normalize($path) { |
|
| 112 | + return $path; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int { |
|
| 116 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function getQueryFilterForStorage(): ISearchOperator { |
|
| 120 | + return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', -1); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { |
|
| 124 | + return null; |
|
| 125 | + } |
|
| 126 | 126 | } |