diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2020-03-26 16:35:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 16:35:30 +0100 |
commit | 0c3e2fac54602926cfa1a0965650481dcaf86743 (patch) | |
tree | ec20e0ffa2f86b9b54939a83a785407319f94559 /tests/lib/Files/Cache | |
parent | 62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff) | |
parent | b80ebc96748b45fd2e0ba9323308657c4b00b7ec (diff) | |
download | nextcloud-server-0c3e2fac54602926cfa1a0965650481dcaf86743.tar.gz nextcloud-server-0c3e2fac54602926cfa1a0965650481dcaf86743.zip |
Merge pull request #20168 from nextcloud/techdebt/short-array-syntax
Use the short array syntax, everywhere
Diffstat (limited to 'tests/lib/Files/Cache')
-rw-r--r-- | tests/lib/Files/Cache/CacheTest.php | 158 | ||||
-rw-r--r-- | tests/lib/Files/Cache/HomeCacheTest.php | 20 | ||||
-rw-r--r-- | tests/lib/Files/Cache/MoveFromCacheTraitTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/Cache/ScannerTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Files/Cache/UpdaterLegacyTest.php | 18 | ||||
-rw-r--r-- | tests/lib/Files/Cache/UpdaterTest.php | 10 | ||||
-rw-r--r-- | tests/lib/Files/Cache/WatcherTest.php | 26 | ||||
-rw-r--r-- | tests/lib/Files/Cache/Wrapper/CacheJailTest.php | 12 | ||||
-rw-r--r-- | tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php | 16 |
9 files changed, 136 insertions, 136 deletions
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index 247ed9ef9ec..40d87214aad 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -55,8 +55,8 @@ class CacheTest extends \Test\TestCase { public function testSimple() { $file1 = 'foo'; $file2 = 'foo/bar'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $data2 = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $data2 = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $this->assertFalse($this->cache->inCache($file1)); $this->assertEquals($this->cache->get($file1), null); @@ -84,7 +84,7 @@ class CacheTest extends \Test\TestCase { $this->assertEquals($id1, $this->cache->getParentId($file2)); $newSize = 1050; - $newId2 = $this->cache->put($file2, array('size' => $newSize)); + $newId2 = $this->cache->put($file2, ['size' => $newSize]); $cacheData2 = $this->cache->get($file2); $this->assertEquals($newId2, $id2); $this->assertEquals($cacheData2['size'], $newSize); @@ -101,14 +101,14 @@ class CacheTest extends \Test\TestCase { public function testPartial() { $file1 = 'foo'; - $this->cache->put($file1, array('size' => 10)); - $this->assertEquals(array('size' => 10), $this->cache->get($file1)); + $this->cache->put($file1, ['size' => 10]); + $this->assertEquals(['size' => 10], $this->cache->get($file1)); - $this->cache->put($file1, array('mtime' => 15)); - $this->assertEquals(array('size' => 10, 'mtime' => 15), $this->cache->get($file1)); + $this->cache->put($file1, ['mtime' => 15]); + $this->assertEquals(['size' => 10, 'mtime' => 15], $this->cache->get($file1)); - $this->cache->put($file1, array('size' => 12)); - $this->assertEquals(array('size' => 12, 'mtime' => 15), $this->cache->get($file1)); + $this->cache->put($file1, ['size' => 12]); + $this->assertEquals(['size' => 12, 'mtime' => 15], $this->cache->get($file1)); } /** @@ -124,10 +124,10 @@ class CacheTest extends \Test\TestCase { } $file2 = $folder . '/bar'; $file3 = $folder . '/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $fileData = array(); - $fileData['bar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; + $fileData = []; + $fileData['bar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($folder, $data1); $this->cache->put($file2, $fileData['bar']); @@ -143,12 +143,12 @@ class CacheTest extends \Test\TestCase { } $file4 = $folder . '/unkownSize'; - $fileData['unkownSize'] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(-1, $this->cache->calculateFolderSize($folder)); - $fileData['unkownSize'] = array('size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(1025, $this->cache->calculateFolderSize($folder)); @@ -164,8 +164,8 @@ class CacheTest extends \Test\TestCase { } public function testRemoveRecursive() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $fileData = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'text/plain'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; + $fileData = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'text/plain']; $folders = ['folder', 'folder/subfolder', 'folder/sub2', 'folder/sub2/sub3']; $files = ['folder/foo.txt', 'folder/bar.txt', 'folder/subfolder/asd.txt', 'folder/sub2/qwerty.txt', 'folder/sub2/sub3/foo.txt']; @@ -184,27 +184,27 @@ class CacheTest extends \Test\TestCase { public function folderDataProvider() { - return array( - array('folder'), + return [ + ['folder'], // that was too easy, try something harder - array('☺, WHITE SMILING FACE, UTF-8 hex E298BA'), + ['☺, WHITE SMILING FACE, UTF-8 hex E298BA'], // what about 4 byte utf-8 - array('😐, NEUTRAL_FACE, UTF-8 hex F09F9890'), + ['😐, NEUTRAL_FACE, UTF-8 hex F09F9890'], // now the crazy stuff - array(', UNASSIGNED PRIVATE USE, UTF-8 hex EF9890'), + [', UNASSIGNED PRIVATE USE, UTF-8 hex EF9890'], // and my favorite - array('w͢͢͝h͡o͢͡ ̸͢k̵͟n̴͘ǫw̸̛s͘ ̀́w͘͢ḩ̵a҉̡͢t ̧̕h́o̵r͏̵rors̡ ̶͡͠lį̶e͟͟ ̶͝in͢ ͏t̕h̷̡͟e ͟͟d̛a͜r̕͡k̢̨ ͡h̴e͏a̷̢̡rt́͏ ̴̷͠ò̵̶f̸ u̧͘ní̛͜c͢͏o̷͏d̸͢e̡͝') - ); + ['w͢͢͝h͡o͢͡ ̸͢k̵͟n̴͘ǫw̸̛s͘ ̀́w͘͢ḩ̵a҉̡͢t ̧̕h́o̵r͏̵rors̡ ̶͡͠lį̶e͟͟ ̶͝in͢ ͏t̕h̷̡͟e ͟͟d̛a͜r̕͡k̢̨ ͡h̴e͏a̷̢̡rt́͏ ̴̷͠ò̵̶f̸ u̧͘ní̛͜c͢͏o̷͏d̸͢e̡͝'] + ]; } public function testEncryptedFolder() { $file1 = 'folder'; $file2 = 'folder/bar'; $file3 = 'folder/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $fileData = array(); - $fileData['bar'] = array('size' => 1000, 'encrypted' => 1, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'encrypted' => 1, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; + $fileData = []; + $fileData['bar'] = ['size' => 1000, 'encrypted' => 1, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'encrypted' => 1, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['bar']); @@ -217,12 +217,12 @@ class CacheTest extends \Test\TestCase { } $file4 = 'folder/unkownSize'; - $fileData['unkownSize'] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(-1, $this->cache->calculateFolderSize($file1)); - $fileData['unkownSize'] = array('size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(1025, $this->cache->calculateFolderSize($file1)); @@ -243,10 +243,10 @@ class CacheTest extends \Test\TestCase { public function testRootFolderSizeForNonHomeStorage() { $dir1 = 'knownsize'; $dir2 = 'unknownsize'; - $fileData = array(); - $fileData[''] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir2] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory'); + $fileData = []; + $fileData[''] = ['size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir1] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir2] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory']; $this->cache->put('', $fileData['']); $this->cache->put($dir1, $fileData[$dir1]); @@ -269,11 +269,11 @@ class CacheTest extends \Test\TestCase { function testStatus() { $this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->getStatus('foo')); - $this->cache->put('foo', array('size' => -1)); + $this->cache->put('foo', ['size' => -1]); $this->assertEquals(\OC\Files\Cache\Cache::PARTIAL, $this->cache->getStatus('foo')); - $this->cache->put('foo', array('size' => -1, 'mtime' => 20, 'mimetype' => 'foo/file')); + $this->cache->put('foo', ['size' => -1, 'mtime' => 20, 'mimetype' => 'foo/file']); $this->assertEquals(\OC\Files\Cache\Cache::SHALLOW, $this->cache->getStatus('foo')); - $this->cache->put('foo', array('size' => 10)); + $this->cache->put('foo', ['size' => 10]); $this->assertEquals(\OC\Files\Cache\Cache::COMPLETE, $this->cache->getStatus('foo')); } @@ -292,7 +292,7 @@ class CacheTest extends \Test\TestCase { public function testPutWithAllKindOfQuotes($fileName) { $this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->get($fileName)); - $this->cache->put($fileName, array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName)); + $this->cache->put($fileName, ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName]); $cacheEntry = $this->cache->get($fileName); $this->assertEquals($fileName, $cacheEntry['etag']); @@ -303,10 +303,10 @@ class CacheTest extends \Test\TestCase { $file1 = 'folder'; $file2 = 'folder/foobar'; $file3 = 'folder/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $fileData = array(); - $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $fileData = []; + $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['foobar']); @@ -339,12 +339,12 @@ class CacheTest extends \Test\TestCase { $file3 = 'folder/foo'; $file4 = 'folder/foo2'; $file5 = 'folder/foo3'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $fileData = array(); - $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); - $fileData['foo2'] = array('size' => 25, 'mtime' => 28, 'mimetype' => 'foo/file'); - $fileData['foo3'] = array('size' => 88, 'mtime' => 34, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $fileData = []; + $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; + $fileData['foo2'] = ['size' => 25, 'mtime' => 28, 'mimetype' => 'foo/file']; + $fileData['foo3'] = ['size' => 88, 'mtime' => 34, 'mimetype' => 'foo/file']; $id1 = $this->cache->put($file1, $data1); $id2 = $this->cache->put($file2, $fileData['foobar']); @@ -387,10 +387,10 @@ class CacheTest extends \Test\TestCase { $file1 = 'folder'; $file2 = 'folder/foobar'; $file3 = 'folder/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $fileData = array(); - $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $fileData = []; + $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['foobar']); @@ -430,8 +430,8 @@ class CacheTest extends \Test\TestCase { * @dataProvider movePathProvider */ function testMove($sourceFolder, $targetFolder, $children) { - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar'); - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar']; + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // create folders foreach ([$sourceFolder, $targetFolder] as $current) { @@ -469,7 +469,7 @@ class CacheTest extends \Test\TestCase { $file2 = 'folder2'; $file3 = 'folder3'; $file4 = 'folder4'; - $data = array('size' => 10, 'mtime' => 50, 'mimetype' => 'foo/bar'); + $data = ['size' => 10, 'mtime' => 50, 'mimetype' => 'foo/bar']; $this->cache->put($file1, $data); $data['size'] = -1; @@ -484,44 +484,44 @@ class CacheTest extends \Test\TestCase { function testNonExisting() { $this->assertFalse($this->cache->get('foo.txt')); $this->assertFalse($this->cache->get(-1)); - $this->assertEquals(array(), $this->cache->getFolderContents('foo')); + $this->assertEquals([], $this->cache->getFolderContents('foo')); } function testGetById() { $storageId = $this->storage->getId(); - $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $id = $this->cache->put('foo', $data); if (strlen($storageId) > 64) { $storageId = md5($storageId); } - $this->assertEquals(array($storageId, 'foo'), \OC\Files\Cache\Cache::getById($id)); + $this->assertEquals([$storageId, 'foo'], \OC\Files\Cache\Cache::getById($id)); } function testStorageMTime() { - $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $this->cache->put('foo', $data); $cachedData = $this->cache->get('foo'); $this->assertEquals($data['mtime'], $cachedData['storage_mtime']); //if no storage_mtime is saved, mtime should be used - $this->cache->put('foo', array('storage_mtime' => 30)); //when setting storage_mtime, mtime is also set + $this->cache->put('foo', ['storage_mtime' => 30]); //when setting storage_mtime, mtime is also set $cachedData = $this->cache->get('foo'); $this->assertEquals(30, $cachedData['storage_mtime']); $this->assertEquals(30, $cachedData['mtime']); - $this->cache->put('foo', array('mtime' => 25)); //setting mtime does not change storage_mtime + $this->cache->put('foo', ['mtime' => 25]); //setting mtime does not change storage_mtime $cachedData = $this->cache->get('foo'); $this->assertEquals(30, $cachedData['storage_mtime']); $this->assertEquals(25, $cachedData['mtime']); } function testLongId() { - $storage = new LongId(array()); + $storage = new LongId([]); $cache = $storage->getCache(); $storageId = $storage->getId(); - $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $id = $cache->put('foo', $data); - $this->assertEquals(array(md5($storageId), 'foo'), \OC\Files\Cache\Cache::getById($id)); + $this->assertEquals([md5($storageId), 'foo'], \OC\Files\Cache\Cache::getById($id)); } /** @@ -546,7 +546,7 @@ class CacheTest extends \Test\TestCase { ->method('normalize') ->willReturnArgument(0); - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // put root folder $this->assertFalse($cacheMock->get('folder')); @@ -586,7 +586,7 @@ class CacheTest extends \Test\TestCase { // folder name "Schön" with U+0308 (un-normalized) $folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e"; - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // put root folder $this->assertFalse($this->cache->get('folder')); @@ -611,12 +611,12 @@ class CacheTest extends \Test\TestCase { } function bogusPathNamesProvider() { - return array( - array('/bogus.txt', 'bogus.txt'), - array('//bogus.txt', 'bogus.txt'), - array('bogus/', 'bogus'), - array('bogus//', 'bogus'), - ); + return [ + ['/bogus.txt', 'bogus.txt'], + ['//bogus.txt', 'bogus.txt'], + ['bogus/', 'bogus'], + ['bogus//', 'bogus'], + ]; } /** @@ -625,7 +625,7 @@ class CacheTest extends \Test\TestCase { * @dataProvider bogusPathNamesProvider */ public function testBogusPaths($bogusPath, $fixedBogusPath) { - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // put root folder $this->assertFalse($this->cache->get('')); @@ -647,12 +647,12 @@ class CacheTest extends \Test\TestCase { } public function testNoReuseOfFileId() { - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain']; $this->cache->put('somefile.txt', $data1); $info = $this->cache->get('somefile.txt'); $fileId = $info['fileid']; $this->cache->remove('somefile.txt'); - $data2 = array('size' => 200, 'mtime' => 100, 'mimetype' => 'text/plain'); + $data2 = ['size' => 200, 'mtime' => 100, 'mimetype' => 'text/plain']; $this->cache->put('anotherfile.txt', $data2); $info2 = $this->cache->get('anotherfile.txt'); $fileId2 = $info2['fileid']; @@ -672,7 +672,7 @@ class CacheTest extends \Test\TestCase { * @dataProvider escapingProvider */ public function testEscaping($name) { - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain']; $this->cache->put($name, $data); $this->assertTrue($this->cache->inCache($name)); $retrievedData = $this->cache->get($name); @@ -684,7 +684,7 @@ class CacheTest extends \Test\TestCase { $this->assertTrue($this->cache->inCache($name . 'asd')); $this->cache->remove($name . 'asd'); $this->assertFalse($this->cache->inCache($name . 'asd')); - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->cache->put($name, $folderData); $this->cache->put('other', $folderData); $childs = ['asd', 'bar', 'foo', 'sub/folder']; @@ -788,8 +788,8 @@ class CacheTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); - $this->storage2 = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); + $this->storage2 = new \OC\Files\Storage\Temporary([]); $this->cache = new \OC\Files\Cache\Cache($this->storage); $this->cache2 = new \OC\Files\Cache\Cache($this->storage2); } diff --git a/tests/lib/Files/Cache/HomeCacheTest.php b/tests/lib/Files/Cache/HomeCacheTest.php index 51fc2e5bc9b..aacb91c675e 100644 --- a/tests/lib/Files/Cache/HomeCacheTest.php +++ b/tests/lib/Files/Cache/HomeCacheTest.php @@ -70,7 +70,7 @@ class HomeCacheTest extends \Test\TestCase { parent::setUp(); $this->user = new DummyUser('foo', \OC::$server->getTempManager()->getTemporaryFolder()); - $this->storage = new \OC\Files\Storage\Home(array('user' => $this->user)); + $this->storage = new \OC\Files\Storage\Home(['user' => $this->user]); $this->cache = $this->storage->getCache(); } @@ -82,11 +82,11 @@ class HomeCacheTest extends \Test\TestCase { public function testRootFolderSizeIgnoresUnknownUpdate() { $dir1 = 'files/knownsize'; $dir2 = 'files/unknownsize'; - $fileData = array(); - $fileData[''] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData['files'] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir2] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory'); + $fileData = []; + $fileData[''] = ['size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData['files'] = ['size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir1] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir2] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory']; $this->cache->put('', $fileData['']); $this->cache->put('files', $fileData['files']); @@ -114,10 +114,10 @@ class HomeCacheTest extends \Test\TestCase { public function testRootFolderSizeIsFilesSize() { $dir1 = 'files'; $afile = 'test.txt'; - $fileData = array(); - $fileData[''] = array('size' => 1500, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$afile] = array('size' => 500, 'mtime' => 20); + $fileData = []; + $fileData[''] = ['size' => 1500, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir1] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$afile] = ['size' => 500, 'mtime' => 20]; $this->cache->put('', $fileData['']); $this->cache->put($dir1, $fileData[$dir1]); diff --git a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php index f93b95b5fe7..6e1430d146b 100644 --- a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php +++ b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php @@ -23,8 +23,8 @@ class MoveFromCacheTraitTest extends CacheTest { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); - $this->storage2 = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); + $this->storage2 = new \OC\Files\Storage\Temporary([]); $this->cache = new FallBackCrossCacheMoveCache($this->storage); $this->cache2 = new FallBackCrossCacheMoveCache($this->storage2); } diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php index 6a025410cc3..52f6697cc6d 100644 --- a/tests/lib/Files/Cache/ScannerTest.php +++ b/tests/lib/Files/Cache/ScannerTest.php @@ -36,7 +36,7 @@ class ScannerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); $this->scanner = new \OC\Files\Cache\Scanner($this->storage); $this->cache = new \OC\Files\Cache\Cache($this->storage); } @@ -247,7 +247,7 @@ class ScannerTest extends \Test\TestCase { $this->scanner->scan(''); $oldData = $this->cache->get(''); $this->storage->unlink('folder/bar.txt'); - $this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder'))); + $this->cache->put('folder', ['mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')]); $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE); $newData = $this->cache->get(''); $this->assertIsString($oldData['etag']); @@ -345,7 +345,7 @@ class ScannerTest extends \Test\TestCase { // delete the folder without removing the childs $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; - \OC_DB::executeAudited($sql, array($oldFolderId)); + \OC_DB::executeAudited($sql, [$oldFolderId]); $cachedData = $this->cache->get('folder/bar.txt'); $this->assertEquals($oldFolderId, $cachedData['parent']); @@ -369,7 +369,7 @@ class ScannerTest extends \Test\TestCase { // delete the folder without removing the childs $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; - \OC_DB::executeAudited($sql, array($oldFolderId)); + \OC_DB::executeAudited($sql, [$oldFolderId]); $cachedData = $this->cache->get('folder/bar.txt'); $this->assertEquals($oldFolderId, $cachedData['parent']); diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php index a3b1a428c28..6366a8eb7eb 100644 --- a/tests/lib/Files/Cache/UpdaterLegacyTest.php +++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php @@ -40,7 +40,7 @@ class UpdaterLegacyTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->storage->mkdir('folder'); @@ -63,7 +63,7 @@ class UpdaterLegacyTest extends \Test\TestCase { Filesystem::init(self::$user, '/' . self::$user . '/files'); Filesystem::clearMounts(); - Filesystem::mount($this->storage, array(), '/' . self::$user . '/files'); + Filesystem::mount($this->storage, [], '/' . self::$user . '/files'); \OC_Hook::clear('OC_Filesystem'); } @@ -85,7 +85,7 @@ class UpdaterLegacyTest extends \Test\TestCase { public function testWrite() { $textSize = strlen("dummy file data\n"); $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png'); - $this->cache->put('foo.txt', array('mtime' => 100, 'storage_mtime' => 150)); + $this->cache->put('foo.txt', ['mtime' => 100, 'storage_mtime' => 150]); $rootCachedData = $this->cache->get(''); $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']); @@ -118,10 +118,10 @@ class UpdaterLegacyTest extends \Test\TestCase { } public function testWriteWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); + $storage2 = new \OC\Files\Storage\Temporary([]); $storage2->getScanner()->scan(''); //initialize etags $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); + Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage'); $view = new View('/' . self::$user . '/files'); $folderCachedData = $view->getFileInfo('folder'); $substorageCachedData = $cache2->get(''); @@ -179,9 +179,9 @@ class UpdaterLegacyTest extends \Test\TestCase { } public function testDeleteWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); + $storage2 = new \OC\Files\Storage\Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); + Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage'); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); $view = new View('/' . self::$user . '/files'); $this->assertTrue($cache2->inCache('foo.txt')); @@ -235,9 +235,9 @@ class UpdaterLegacyTest extends \Test\TestCase { } public function testRenameWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); + $storage2 = new \OC\Files\Storage\Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); + Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage'); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); $view = new View('/' . self::$user . '/files'); $this->assertTrue($cache2->inCache('foo.txt')); diff --git a/tests/lib/Files/Cache/UpdaterTest.php b/tests/lib/Files/Cache/UpdaterTest.php index 8dc5893007b..f8880d0f2a8 100644 --- a/tests/lib/Files/Cache/UpdaterTest.php +++ b/tests/lib/Files/Cache/UpdaterTest.php @@ -45,7 +45,7 @@ class UpdaterTest extends \Test\TestCase { $this->loginAsUser(); - $this->storage = new Temporary(array()); + $this->storage = new Temporary([]); $this->updater = $this->storage->getUpdater(); $this->cache = $this->storage->getCache(); } @@ -220,9 +220,9 @@ class UpdaterTest extends \Test\TestCase { } public function testMoveCrossStorage() { - $storage2 = new Temporary(array()); + $storage2 = new Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/bar'); + Filesystem::mount($storage2, [], '/bar'); $this->storage->file_put_contents('foo.txt', 'qwerty'); $this->updater->update('foo.txt'); @@ -251,9 +251,9 @@ class UpdaterTest extends \Test\TestCase { } public function testMoveFolderCrossStorage() { - $storage2 = new Temporary(array()); + $storage2 = new Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/bar'); + Filesystem::mount($storage2, [], '/bar'); $this->storage->mkdir('foo'); $this->storage->mkdir('foo/bar'); $this->storage->file_put_contents('foo/foo.txt', 'qwerty'); diff --git a/tests/lib/Files/Cache/WatcherTest.php b/tests/lib/Files/Cache/WatcherTest.php index 18f0ebe98a9..2a42a9e603f 100644 --- a/tests/lib/Files/Cache/WatcherTest.php +++ b/tests/lib/Files/Cache/WatcherTest.php @@ -20,7 +20,7 @@ class WatcherTest extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage[] $storages */ - private $storages = array(); + private $storages = []; protected function setUp(): void { parent::setUp(); @@ -49,7 +49,7 @@ class WatcherTest extends \Test\TestCase { $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); //set the mtime to the past so it can detect an mtime change - $cache->put('', array('storage_mtime' => 10)); + $cache->put('', ['storage_mtime' => 10]); $this->assertTrue($cache->inCache('folder/bar.txt')); $this->assertTrue($cache->inCache('folder/bar2.txt')); @@ -61,7 +61,7 @@ class WatcherTest extends \Test\TestCase { $cachedData = $cache->get('bar.test'); $this->assertEquals(3, $cachedData['size']); - $cache->put('bar.test', array('storage_mtime' => 10)); + $cache->put('bar.test', ['storage_mtime' => 10]); $storage->file_put_contents('bar.test', 'test data'); // make sure that PHP can read the new size correctly @@ -71,7 +71,7 @@ class WatcherTest extends \Test\TestCase { $cachedData = $cache->get('bar.test'); $this->assertEquals(9, $cachedData['size']); - $cache->put('folder', array('storage_mtime' => 10)); + $cache->put('folder', ['storage_mtime' => 10]); $storage->unlink('folder/bar2.txt'); $updater->checkUpdate('folder'); @@ -90,7 +90,7 @@ class WatcherTest extends \Test\TestCase { $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); //set the mtime to the past so it can detect an mtime change - $cache->put('', array('storage_mtime' => 10)); + $cache->put('', ['storage_mtime' => 10]); $storage->unlink('foo.txt'); $storage->rename('folder', 'foo.txt'); @@ -107,7 +107,7 @@ class WatcherTest extends \Test\TestCase { $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $storage->unlink('foo.txt'); $storage->rename('folder', 'foo.txt'); @@ -124,14 +124,14 @@ class WatcherTest extends \Test\TestCase { $updater = $storage->getWatcher(); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_NEVER); $storage->file_put_contents('foo.txt', 'q'); $this->assertFalse($updater->checkUpdate('foo.txt')); - $cache->put('foo.txt', array('storage_mtime' => 20)); + $cache->put('foo.txt', ['storage_mtime' => 20]); $storage->file_put_contents('foo.txt', 'w'); $this->assertFalse($updater->checkUpdate('foo.txt')); } @@ -142,14 +142,14 @@ class WatcherTest extends \Test\TestCase { $updater = $storage->getWatcher(); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); $storage->file_put_contents('foo.txt', 'q'); $this->assertTrue($updater->checkUpdate('foo.txt')); - $cache->put('foo.txt', array('storage_mtime' => 20)); + $cache->put('foo.txt', ['storage_mtime' => 20]); $storage->file_put_contents('foo.txt', 'w'); $this->assertFalse($updater->checkUpdate('foo.txt')); } @@ -160,14 +160,14 @@ class WatcherTest extends \Test\TestCase { $updater = $storage->getWatcher(); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ALWAYS); $storage->file_put_contents('foo.txt', 'q'); $this->assertTrue($updater->checkUpdate('foo.txt')); - $cache->put('foo.txt', array('storage_mtime' => 20)); + $cache->put('foo.txt', ['storage_mtime' => 20]); $storage->file_put_contents('foo.txt', 'w'); $this->assertTrue($updater->checkUpdate('foo.txt')); } @@ -177,7 +177,7 @@ class WatcherTest extends \Test\TestCase { * @return \OC\Files\Storage\Storage */ private function getTestStorage($scan = true) { - $storage = new \OC\Files\Storage\Temporary(array()); + $storage = new \OC\Files\Storage\Temporary([]); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $storage->mkdir('folder'); diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php index 9c1a8c14101..5d7e9f8ec08 100644 --- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php +++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php @@ -34,7 +34,7 @@ class CacheJailTest extends CacheTest { function testSearchOutsideJail() { $file1 = 'foo/foobar'; $file2 = 'folder/foobar'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; $this->sourceCache->put($file1, $data1); $this->sourceCache->put($file2, $data1); @@ -50,7 +50,7 @@ class CacheJailTest extends CacheTest { $file1 = 'foo/foobar'; $file2 = 'foo/foobar/asd'; $file3 = 'folder/foobar'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('foo', $data1); $this->sourceCache->put($file1, $data1); @@ -64,7 +64,7 @@ class CacheJailTest extends CacheTest { } function testGetById() { - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $id = $this->sourceCache->put('foo/bar', $data1); // path from jailed foo of foo/bar is bar @@ -83,7 +83,7 @@ class CacheJailTest extends CacheTest { } function testMoveFromJail() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('source', $folderData); $this->sourceCache->put('source/foo', $folderData); @@ -99,7 +99,7 @@ class CacheJailTest extends CacheTest { } function testMoveToJail() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('source', $folderData); $this->sourceCache->put('source/foo', $folderData); @@ -115,7 +115,7 @@ class CacheJailTest extends CacheTest { } function testMoveBetweenJail() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('source', $folderData); $this->sourceCache->put('source/foo', $folderData); diff --git a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php index 9883fc1da27..20c20974c07 100644 --- a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php +++ b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php @@ -36,12 +36,12 @@ class CachePermissionsMaskTest extends CacheTest { } public function maskProvider() { - return array( - array(Constants::PERMISSION_ALL), - array(Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE), - array(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE), - array(Constants::PERMISSION_READ) - ); + return [ + [Constants::PERMISSION_ALL], + [Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE], + [Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE], + [Constants::PERMISSION_READ] + ]; } /** @@ -50,12 +50,12 @@ class CachePermissionsMaskTest extends CacheTest { */ public function testGetMasked($mask) { $cache = $this->getMaskedCached($mask); - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL]; $this->sourceCache->put('foo', $data); $result = $cache->get('foo'); $this->assertEquals($mask, $result['permissions']); - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE]; $this->sourceCache->put('bar', $data); $result = $cache->get('bar'); $this->assertEquals($mask & ~Constants::PERMISSION_DELETE, $result['permissions']); |