diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-26 09:30:18 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-26 16:34:56 +0100 |
commit | b80ebc96748b45fd2e0ba9323308657c4b00b7ec (patch) | |
tree | ec20e0ffa2f86b9b54939a83a785407319f94559 /tests/lib/Files | |
parent | 62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff) | |
download | nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.tar.gz nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.zip |
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Files')
30 files changed, 326 insertions, 326 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']); diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php index d3b372fe137..8c6dd1964ab 100644 --- a/tests/lib/Files/EtagTest.php +++ b/tests/lib/Files/EtagTest.php @@ -67,7 +67,7 @@ class EtagTest extends \Test\TestCase { Filesystem::file_put_contents('/folder/bar.txt', 'fgh'); Filesystem::file_put_contents('/folder/subfolder/qwerty.txt', 'jkl'); - $files = array('/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt'); + $files = ['/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt']; $originalEtags = $this->getEtags($files); $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); @@ -84,7 +84,7 @@ class EtagTest extends \Test\TestCase { * @param string[] $files */ private function getEtags($files) { - $etags = array(); + $etags = []; foreach ($files as $file) { $info = Filesystem::getFileInfo($file); $etags[$file] = $info['etag']; diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php index 6d0362772ca..d98256501b1 100644 --- a/tests/lib/Files/FilesystemTest.php +++ b/tests/lib/Files/FilesystemTest.php @@ -66,7 +66,7 @@ class FilesystemTest extends \Test\TestCase { /** * @var array tmpDirs */ - private $tmpDirs = array(); + private $tmpDirs = []; /** * @return array @@ -74,7 +74,7 @@ class FilesystemTest extends \Test\TestCase { private function getStorageData() { $dir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->tmpDirs[] = $dir; - return array('datadir' => $dir); + return ['datadir' => $dir]; } protected function setUp(): void { @@ -225,29 +225,29 @@ class FilesystemTest extends \Test\TestCase { } public function isValidPathData() { - return array( - array('/', true), - array('/path', true), - array('/foo/bar', true), - array('/foo//bar/', true), - array('/foo////bar', true), - array('/foo//\///bar', true), - array('/foo/bar/.', true), - array('/foo/bar/./', true), - array('/foo/bar/./.', true), - array('/foo/bar/././', true), - array('/foo/bar/././..bar', true), - array('/foo/bar/././..bar/a', true), - array('/foo/bar/././..', false), - array('/foo/bar/././../', false), - array('/foo/bar/.././', false), - array('/foo/bar/../../', false), - array('/foo/bar/../..\\', false), - array('..', false), - array('../', false), - array('../foo/bar', false), - array('..\foo/bar', false), - ); + return [ + ['/', true], + ['/path', true], + ['/foo/bar', true], + ['/foo//bar/', true], + ['/foo////bar', true], + ['/foo//\///bar', true], + ['/foo/bar/.', true], + ['/foo/bar/./', true], + ['/foo/bar/./.', true], + ['/foo/bar/././', true], + ['/foo/bar/././..bar', true], + ['/foo/bar/././..bar/a', true], + ['/foo/bar/././..', false], + ['/foo/bar/././../', false], + ['/foo/bar/.././', false], + ['/foo/bar/../../', false], + ['/foo/bar/../..\\', false], + ['..', false], + ['../', false], + ['../foo/bar', false], + ['..\foo/bar', false], + ]; } /** @@ -258,18 +258,18 @@ class FilesystemTest extends \Test\TestCase { } public function isFileBlacklistedData() { - return array( - array('/etc/foo/bar/foo.txt', false), - array('\etc\foo/bar\foo.txt', false), - array('.htaccess', true), - array('.htaccess/', true), - array('.htaccess\\', true), - array('/etc/foo\bar/.htaccess\\', true), - array('/etc/foo\bar/.htaccess/', true), - array('/etc/foo\bar/.htaccess/foo', false), - array('//foo//bar/\.htaccess/', true), - array('\foo\bar\.HTAccess', true), - ); + return [ + ['/etc/foo/bar/foo.txt', false], + ['\etc\foo/bar\foo.txt', false], + ['.htaccess', true], + ['.htaccess/', true], + ['.htaccess\\', true], + ['/etc/foo\bar/.htaccess\\', true], + ['/etc/foo\bar/.htaccess/', true], + ['/etc/foo\bar/.htaccess/foo', false], + ['//foo//bar/\.htaccess/', true], + ['\foo\bar\.HTAccess', true], + ]; } /** @@ -304,7 +304,7 @@ class FilesystemTest extends \Test\TestCase { \OC_Hook::clear('OC_Filesystem'); \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); - \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/'); + \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', [], '/'); $rootView = new \OC\Files\View(''); $rootView->mkdir('/' . $user); diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php index f3cdc4264e4..1e80ec17ea1 100644 --- a/tests/lib/Files/Mount/ManagerTest.php +++ b/tests/lib/Files/Mount/ManagerTest.php @@ -30,39 +30,39 @@ class ManagerTest extends \Test\TestCase { public function testFind() { $this->assertNull($this->manager->find('/')); - $rootMount = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/'); + $rootMount = new \OC\Files\Mount\MountPoint(new Temporary([]), '/'); $this->manager->addMount($rootMount); $this->assertEquals($rootMount, $this->manager->find('/')); $this->assertEquals($rootMount, $this->manager->find('/foo/bar')); - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount1 = new \OC\Files\Mount\MountPoint($storage, '/foo'); $this->manager->addMount($mount1); $this->assertEquals($rootMount, $this->manager->find('/')); $this->assertEquals($mount1, $this->manager->find('/foo/bar')); $this->assertEquals(1, count($this->manager->findIn('/'))); - $mount2 = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/bar'); + $mount2 = new \OC\Files\Mount\MountPoint(new Temporary([]), '/bar'); $this->manager->addMount($mount2); $this->assertEquals(2, count($this->manager->findIn('/'))); $id = $mount1->getStorageId(); - $this->assertEquals(array($mount1), $this->manager->findByStorageId($id)); + $this->assertEquals([$mount1], $this->manager->findByStorageId($id)); $mount3 = new \OC\Files\Mount\MountPoint($storage, '/foo/bar'); $this->manager->addMount($mount3); - $this->assertEquals(array($mount1, $mount3), $this->manager->findByStorageId($id)); + $this->assertEquals([$mount1, $mount3], $this->manager->findByStorageId($id)); } public function testLong() { - $storage = new LongId(array()); + $storage = new LongId([]); $mount = new \OC\Files\Mount\MountPoint($storage, '/foo'); $this->manager->addMount($mount); $id = $mount->getStorageId(); $storageId = $storage->getId(); - $this->assertEquals(array($mount), $this->manager->findByStorageId($id)); - $this->assertEquals(array($mount), $this->manager->findByStorageId($storageId)); - $this->assertEquals(array($mount), $this->manager->findByStorageId(md5($storageId))); + $this->assertEquals([$mount], $this->manager->findByStorageId($id)); + $this->assertEquals([$mount], $this->manager->findByStorageId($storageId)); + $this->assertEquals([$mount], $this->manager->findByStorageId(md5($storageId))); } } diff --git a/tests/lib/Files/Mount/MountTest.php b/tests/lib/Files/Mount/MountTest.php index f21095f2fa5..160545e784c 100644 --- a/tests/lib/Files/Mount/MountTest.php +++ b/tests/lib/Files/Mount/MountTest.php @@ -31,7 +31,7 @@ class MountTest extends \Test\TestCase { $wrapper = function ($mountPoint, $storage) use (&$test) { $test->assertEquals('/foo/', $mountPoint); $test->assertInstanceOf('\OC\Files\Storage\Storage', $storage); - return new Wrapper(array('storage' => $storage)); + return new Wrapper(['storage' => $storage]); }; $loader = new StorageFactory(); @@ -40,7 +40,7 @@ class MountTest extends \Test\TestCase { $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') ->disableOriginalConstructor() ->getMock(); - $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', array(), $loader); + $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', [], $loader); $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage()); } } diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php index 69d31b28a96..c6f468b796b 100644 --- a/tests/lib/Files/Node/FileTest.php +++ b/tests/lib/Files/Node/FileTest.php @@ -53,7 +53,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $this->assertEquals('bar', $node->getContent()); @@ -75,7 +75,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => 0))); + ->willReturn($this->getFileInfo(['permissions' => 0])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->getContent(); @@ -94,7 +94,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $this->view->expects($this->once()) ->method('file_put_contents') @@ -117,7 +117,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->putContent('bar'); @@ -132,7 +132,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('mimetype' => 'text/plain'))); + ->willReturn($this->getFileInfo(['mimetype' => 'text/plain'])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $this->assertEquals('text/plain', $node->getMimeType()); @@ -167,7 +167,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $fh = $node->fopen('r'); @@ -202,7 +202,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $fh = $node->fopen('w'); @@ -232,7 +232,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => 0))); + ->willReturn($this->getFileInfo(['permissions' => 0])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('r'); @@ -257,7 +257,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_UPDATE))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_UPDATE])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); @@ -282,7 +282,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 979c7fd6da6..83ebc478370 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -64,10 +64,10 @@ class FolderTest extends NodeTest { $view->expects($this->any()) ->method('getDirectoryContent') ->with('/bar/foo') - ->willReturn(array( + ->willReturn([ new FileInfo('/bar/foo/asd', null, 'foo/asd', ['fileid' => 2, 'path' => '/bar/foo/asd', 'name' => 'asd', 'size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'], null), new FileInfo('/bar/foo/qwerty', null, 'foo/qwerty', ['fileid' => 3, 'path' => '/bar/foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'httpd/unix-directory'], null) - )); + ]); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $children = $node->getDirectoryListing(); @@ -163,7 +163,7 @@ class FolderTest extends NodeTest { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $view->expects($this->once()) ->method('mkdir') @@ -195,7 +195,7 @@ class FolderTest extends NodeTest { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFolder('asd'); @@ -217,7 +217,7 @@ class FolderTest extends NodeTest { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $view->expects($this->once()) ->method('touch') @@ -249,7 +249,7 @@ class FolderTest extends NodeTest { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFile('asd'); @@ -308,14 +308,14 @@ class FolderTest extends NodeTest { $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->willReturn(array( - array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - )); + ->willReturn([ + ['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->willReturn(array()); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') @@ -361,15 +361,15 @@ class FolderTest extends NodeTest { $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->willReturn(array( - array('fileid' => 3, 'path' => 'files/foo', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'), - array('fileid' => 3, 'path' => 'files_trashbin/foo2.d12345', 'name' => 'foo2.d12345', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'), - )); + ->willReturn([ + ['fileid' => 3, 'path' => 'files/foo', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'], + ['fileid' => 3, 'path' => 'files_trashbin/foo2.d12345', 'name' => 'foo2.d12345', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'], + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('') - ->willReturn(array()); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') @@ -412,14 +412,14 @@ class FolderTest extends NodeTest { $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->willReturn(array( - array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - )); + ->willReturn([ + ['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar') - ->willReturn(array()); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') @@ -478,21 +478,21 @@ class FolderTest extends NodeTest { $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->willReturn(array( - array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - )); + ->willReturn([ + ['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $subCache->expects($this->once()) ->method('search') ->with('%qw%') - ->willReturn(array( - array('fileid' => 4, 'path' => 'asd/qweasd', 'name' => 'qweasd', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - )); + ->willReturn([ + ['fileid' => 4, 'path' => 'asd/qweasd', 'name' => 'qweasd', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->willReturn(array($subMount)); + ->willReturn([$subMount]); $root->expects($this->once()) ->method('getMount') @@ -556,7 +556,7 @@ class FolderTest extends NodeTest { $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->willReturn(array()); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') @@ -659,7 +659,7 @@ class FolderTest extends NodeTest { $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->willReturn(array()); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') @@ -727,7 +727,7 @@ class FolderTest extends NodeTest { $root->expects($this->any()) ->method('getMountsIn') ->with('/bar/foo') - ->willReturn(array($mount2)); + ->willReturn([$mount2]); $root->expects($this->once()) ->method('getMount') diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index 2a542a1097a..26cdf398d94 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -57,8 +57,8 @@ class IntegrationTest extends \Test\TestCase { $this->createMock(ILogger::class), $this->createMock(IUserManager::class) ); - $storage = new Temporary(array()); - $subStorage = new Temporary(array()); + $storage = new Temporary([]); + $subStorage = new Temporary([]); $this->storages[] = $storage; $this->storages[] = $subStorage; $this->root->mount($storage, '/'); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index 18cc4d80574..b963a395560 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -203,13 +203,13 @@ abstract class NodeTest extends \Test\TestCase { ->method('getUser') ->willReturn($this->user); - $stat = array( + $stat = [ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50, 'permissions' => 0 - ); + ]; $this->view->expects($this->once()) ->method('stat') @@ -225,12 +225,12 @@ abstract class NodeTest extends \Test\TestCase { ->method('getUser') ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') @@ -247,12 +247,12 @@ abstract class NodeTest extends \Test\TestCase { ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') @@ -268,12 +268,12 @@ abstract class NodeTest extends \Test\TestCase { ->method('getUser') ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') @@ -289,12 +289,12 @@ abstract class NodeTest extends \Test\TestCase { ->method('getUser') ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') @@ -319,7 +319,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('resolvePath') ->with('/bar/foo') - ->willReturn(array($storage, 'foo')); + ->willReturn([$storage, 'foo']); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); @@ -349,7 +349,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('resolvePath') ->with('/bar/foo') - ->willReturn(array($storage, 'foo')); + ->willReturn([$storage, 'foo']); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); @@ -378,7 +378,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $node->touch(100); @@ -425,12 +425,12 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('resolvePath') ->with('/bar/foo') - ->willReturn(array(null, 'foo')); + ->willReturn([null, 'foo']); $this->view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = $this->createTestNode($root, $this->view, '/bar/foo'); $node->touch(100); @@ -448,7 +448,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $node->touch(100); diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index 6c4189bdec7..c78bef07627 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -79,7 +79,7 @@ class RootTest extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->willReturn($this->getFileInfo(array('fileid' => 10, 'path' => 'bar/foo', 'name', 'mimetype' => 'text/plain'))); + ->willReturn($this->getFileInfo(['fileid' => 10, 'path' => 'bar/foo', 'name', 'mimetype' => 'text/plain'])); $root->mount($storage, ''); $node = $root->get('/bar/foo'); diff --git a/tests/lib/Files/ObjectStore/NoopScannerTest.php b/tests/lib/Files/ObjectStore/NoopScannerTest.php index 8b879e8ab37..570fc16ee98 100644 --- a/tests/lib/Files/ObjectStore/NoopScannerTest.php +++ b/tests/lib/Files/ObjectStore/NoopScannerTest.php @@ -22,7 +22,7 @@ class NoopScannerTest 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\ObjectStore\NoopScanner($this->storage); } diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php index 91b24d8b615..b56978f4fee 100644 --- a/tests/lib/Files/ObjectStore/S3Test.php +++ b/tests/lib/Files/ObjectStore/S3Test.php @@ -34,11 +34,11 @@ class MultiPartUploadS3 extends S3 { class NonSeekableStream extends Wrapper { public static function wrap($source) { - $context = stream_context_create(array( - 'nonseek' => array( + $context = stream_context_create([ + 'nonseek' => [ 'source' => $source - ) - )); + ] + ]); return Wrapper::wrapSource($source, $context, 'nonseek', self::class); } diff --git a/tests/lib/Files/Storage/HomeTest.php b/tests/lib/Files/Storage/HomeTest.php index 6075e9af293..d5feb40840f 100644 --- a/tests/lib/Files/Storage/HomeTest.php +++ b/tests/lib/Files/Storage/HomeTest.php @@ -73,7 +73,7 @@ class HomeTest extends Storage { $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->userId = $this->getUniqueID('user_'); $this->user = new DummyUser($this->userId, $this->tmpDir); - $this->instance = new \OC\Files\Storage\Home(array('user' => $this->user)); + $this->instance = new \OC\Files\Storage\Home(['user' => $this->user]); } protected function tearDown(): void { diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index 23738a25c2a..46784811248 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -39,7 +39,7 @@ class LocalTest extends Storage { parent::setUp(); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); + $this->instance = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); } protected function tearDown(): void { diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php index a25a3f74f9e..736cbfff4f0 100644 --- a/tests/lib/Files/Storage/Storage.php +++ b/tests/lib/Files/Storage/Storage.php @@ -80,13 +80,13 @@ abstract class Storage extends \Test\TestCase { $this->assertTrue($this->instance->isUpdatable('/' . $directory)); $dh = $this->instance->opendir('/'); - $content = array(); + $content = []; while ($file = readdir($dh)) { if ($file != '.' and $file != '..') { $content[] = $file; } } - $this->assertEquals(array($directory), $content); + $this->assertEquals([$directory], $content); $this->assertFalse($this->instance->mkdir('/' . $directory)); //can't create existing folders $this->assertTrue($this->instance->rmdir('/' . $directory)); @@ -97,13 +97,13 @@ abstract class Storage extends \Test\TestCase { $this->assertFalse($this->instance->rmdir('/' . $directory)); //can't remove non existing folders $dh = $this->instance->opendir('/'); - $content = array(); + $content = []; while ($file = readdir($dh)) { if ($file != '.' and $file != '..') { $content[] = $file; } } - $this->assertEquals(array(), $content); + $this->assertEquals([], $content); } public function fileNameProvider() { @@ -130,12 +130,12 @@ abstract class Storage extends \Test\TestCase { function loremFileProvider() { $root = \OC::$SERVERROOT . '/tests/data/'; - return array( + return [ // small file - array($root . 'lorem.txt'), + [$root . 'lorem.txt'], // bigger file (> 8 KB which is the standard PHP block size) - array($root . 'lorem-big.txt') - ); + [$root . 'lorem-big.txt'] + ]; } /** @@ -413,11 +413,11 @@ abstract class Storage extends \Test\TestCase { } public function hashProvider() { - return array( - array('Foobar', 'md5'), - array('Foobar', 'sha1'), - array('Foobar', 'sha256'), - ); + return [ + ['Foobar', 'md5'], + ['Foobar', 'sha1'], + ['Foobar', 'sha256'], + ]; } /** @@ -438,14 +438,14 @@ abstract class Storage extends \Test\TestCase { $this->assertEquals('data', $this->instance->file_get_contents('#foo/test.txt')); $dh = $this->instance->opendir('#foo'); - $content = array(); + $content = []; while ($file = readdir($dh)) { if ($file != '.' and $file != '..') { $content[] = $file; } } - $this->assertEquals(array('test.txt'), $content); + $this->assertEquals(['test.txt'], $content); } public function testCopyOverWriteFile() { diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index a9d678e76e9..ac3880309c0 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -148,7 +148,7 @@ class EncryptionTest extends Storage { $this->logger = $this->createMock(Log::class); - $this->sourceStorage = new Temporary(array()); + $this->sourceStorage = new Temporary([]); $this->keyStore = $this->getMockBuilder('\OC\Encryption\Keys\Storage') ->disableOriginalConstructor()->getMock(); @@ -458,13 +458,13 @@ class EncryptionTest extends Storage { * @return array */ public function dataTestCopyAndRename() { - return array( - array('source', 'target', true, false, false), - array('source', 'target', true, true, false), - array('source', '/subFolder/target', true, false, false), - array('source', '/subFolder/target', true, true, true), - array('source', '/subFolder/target', false, true, false), - ); + return [ + ['source', 'target', true, false, false], + ['source', 'target', true, true, false], + ['source', '/subFolder/target', true, false, false], + ['source', '/subFolder/target', true, true, true], + ['source', '/subFolder/target', false, true, false], + ]; } public function testIsLocal() { @@ -512,16 +512,16 @@ class EncryptionTest extends Storage { } public function dataTestRmdir() { - return array( - array('/file.txt', true, true, true), - array('/file.txt', false, true, true), - array('/file.txt', true, false, true), - array('/file.txt', false, false, true), - array('/file.txt', true, true, false), - array('/file.txt', false, true, false), - array('/file.txt', true, false, false), - array('/file.txt', false, false, false), - ); + return [ + ['/file.txt', true, true, true], + ['/file.txt', false, true, true], + ['/file.txt', true, false, true], + ['/file.txt', false, false, true], + ['/file.txt', true, true, false], + ['/file.txt', false, true, false], + ['/file.txt', true, false, false], + ['/file.txt', false, false, false], + ]; } /** @@ -547,10 +547,10 @@ class EncryptionTest extends Storage { } public function dataTestCopyKeys() { - return array( - array(true, false), - array(false, true), - ); + return [ + [true, false], + [false, true], + ]; } /** @@ -613,13 +613,13 @@ class EncryptionTest extends Storage { } public function dataTestGetHeader() { - return array( - array('/foo/bar.txt', false, '/foo/bar.txt'), - array('/foo/bar.txt.part', false, '/foo/bar.txt'), - array('/foo/bar.txt.ocTransferId7437493.part', false, '/foo/bar.txt'), - array('/foo/bar.txt.part', true, '/foo/bar.txt'), - array('/foo/bar.txt.ocTransferId7437493.part', true, '/foo/bar.txt'), - ); + return [ + ['/foo/bar.txt', false, '/foo/bar.txt'], + ['/foo/bar.txt.part', false, '/foo/bar.txt'], + ['/foo/bar.txt.ocTransferId7437493.part', false, '/foo/bar.txt'], + ['/foo/bar.txt.part', true, '/foo/bar.txt'], + ['/foo/bar.txt.ocTransferId7437493.part', true, '/foo/bar.txt'], + ]; } /** diff --git a/tests/lib/Files/Storage/Wrapper/JailTest.php b/tests/lib/Files/Storage/Wrapper/JailTest.php index cb7003cb7ea..6c8905af765 100644 --- a/tests/lib/Files/Storage/Wrapper/JailTest.php +++ b/tests/lib/Files/Storage/Wrapper/JailTest.php @@ -17,24 +17,24 @@ class JailTest extends \Test\Files\Storage\Storage { protected function setUp(): void { parent::setUp(); - $this->sourceStorage = new \OC\Files\Storage\Temporary(array()); + $this->sourceStorage = new \OC\Files\Storage\Temporary([]); $this->sourceStorage->mkdir('foo'); - $this->instance = new \OC\Files\Storage\Wrapper\Jail(array( + $this->instance = new \OC\Files\Storage\Wrapper\Jail([ 'storage' => $this->sourceStorage, 'root' => 'foo' - )); + ]); } protected function tearDown(): void { // test that nothing outside our jail is touched - $contents = array(); + $contents = []; $dh = $this->sourceStorage->opendir(''); while ($file = readdir($dh)) { if (!\OC\Files\Filesystem::isIgnoredDir($file)) { $contents[] = $file; } } - $this->assertEquals(array('foo'), $contents); + $this->assertEquals(['foo'], $contents); $this->sourceStorage->cleanUp(); parent::tearDown(); } diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php index bfdd3d3ddbb..1e69ee7165e 100644 --- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php +++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php @@ -24,7 +24,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage { protected function setUp(): void { parent::setUp(); - $this->sourceStorage = new \OC\Files\Storage\Temporary(array()); + $this->sourceStorage = new \OC\Files\Storage\Temporary([]); $this->instance = $this->getMaskedStorage(Constants::PERMISSION_ALL); } @@ -34,10 +34,10 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage { } protected function getMaskedStorage($mask) { - return new \OC\Files\Storage\Wrapper\PermissionsMask(array( + return new \OC\Files\Storage\Wrapper\PermissionsMask([ 'storage' => $this->sourceStorage, 'mask' => $mask - )); + ]); } public function testMkdirNoCreate() { @@ -129,10 +129,10 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage { public function testScanNewFilesNested() { $storage = $this->getMaskedStorage(Constants::PERMISSION_READ + Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE); - $nestedStorage = new \OC\Files\Storage\Wrapper\PermissionsMask(array( + $nestedStorage = new \OC\Files\Storage\Wrapper\PermissionsMask([ 'storage' => $storage, 'mask' => Constants::PERMISSION_READ + Constants::PERMISSION_CREATE - )); + ]); $wrappedStorage = new Wrapper(['storage' => $nestedStorage]); $wrappedStorage->file_put_contents('foo', 'bar'); $wrappedStorage->getScanner()->scan(''); diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index 164541b670c..65cfe30eb1c 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -31,8 +31,8 @@ class QuotaTest extends \Test\Files\Storage\Storage { parent::setUp(); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); - $this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000)); + $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); + $this->instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 10000000]); } protected function tearDown(): void { @@ -44,10 +44,10 @@ class QuotaTest extends \Test\Files\Storage\Storage { * @param integer $limit */ protected function getLimitedStorage($limit) { - $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); + $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); $storage->mkdir('files'); $storage->getScanner()->scan(''); - return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $limit)); + return new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => $limit]); } public function testFilePutContentsNotEnoughSpace() { @@ -70,7 +70,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { public function testFreeSpaceWithUsedSpace() { $instance = $this->getLimitedStorage(9); $instance->getCache()->put( - '', array('size' => 3) + '', ['size' => 3] ); $this->assertEquals(6, $instance->free_space('')); } @@ -85,9 +85,9 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->willReturn(-2); $storage->getScanner()->scan(''); - $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 9)); + $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 9]); $instance->getCache()->put( - '', array('size' => 3) + '', ['size' => 3] ); $this->assertEquals(6, $instance->free_space('')); } @@ -95,7 +95,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { public function testFreeSpaceWithUsedSpaceAndEncryption() { $instance = $this->getLimitedStorage(9); $instance->getCache()->put( - '', array('size' => 7) + '', ['size' => 7] ); $this->assertEquals(2, $instance->free_space('')); } @@ -140,7 +140,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->method('fopen') ->willReturn(false); - $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $failStorage, 'quota' => 1000)); + $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $failStorage, 'quota' => 1000]); $this->assertFalse($instance->fopen('failedfopen', 'r')); } @@ -198,7 +198,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->with('files') ->willReturn(new CacheEntry(['size' => 50])); - $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 1024, 'root' => 'files')); + $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 1024, 'root' => 'files']); $this->assertEquals(1024 - 50, $instance->free_space('')); } diff --git a/tests/lib/Files/Storage/Wrapper/WrapperTest.php b/tests/lib/Files/Storage/Wrapper/WrapperTest.php index 2477b361bc1..b9bb54e09b2 100644 --- a/tests/lib/Files/Storage/Wrapper/WrapperTest.php +++ b/tests/lib/Files/Storage/Wrapper/WrapperTest.php @@ -18,8 +18,8 @@ class WrapperTest extends \Test\Files\Storage\Storage { parent::setUp(); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); - $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage)); + $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); + $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(['storage' => $storage]); } protected function tearDown(): void { diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index e55dae98cb6..43114ff70f3 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -101,7 +101,7 @@ class EncryptionTest extends \Test\TestCase { $fileMock->expects($this->once())->method('getAccessList') ->willReturnCallback(function ($sharePath) use ($expectedSharePath) { $this->assertSame($expectedSharePath, $sharePath); - return array(); + return []; }); } $utilMock = $this->getMockBuilder('\OC\Encryption\Util') @@ -138,7 +138,7 @@ class EncryptionTest extends \Test\TestCase { $fullPathP->setAccessible(false); $header = $stream->getProperty('header'); $header->setAccessible(true); - $header->setValue($streamWrapper, array()); + $header->setValue($streamWrapper, []); $header->setAccessible(false); $this->invokePrivate($streamWrapper, 'signed', [true]); diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php index 9d82e4ae1e1..c5183ac3929 100644 --- a/tests/lib/Files/Utils/ScannerTest.php +++ b/tests/lib/Files/Utils/ScannerTest.php @@ -21,7 +21,7 @@ class TestScanner extends \OC\Files\Utils\Scanner { /** * @var \OC\Files\Mount\MountPoint[] $mounts */ - private $mounts = array(); + private $mounts = []; /** * @param \OC\Files\Mount\MountPoint $mount @@ -63,7 +63,7 @@ class ScannerTest extends \Test\TestCase { } public function testReuseExistingRoot() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -85,7 +85,7 @@ class ScannerTest extends \Test\TestCase { } public function testReuseExistingFile() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -112,7 +112,7 @@ class ScannerTest extends \Test\TestCase { $mountProvider = $this->createMock(IMountProvider::class); - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, '/' . $uid . '/files/foo'); $mountProvider->expects($this->any()) @@ -169,7 +169,7 @@ class ScannerTest extends \Test\TestCase { } public function testPropagateEtag() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -213,7 +213,7 @@ class ScannerTest extends \Test\TestCase { } public function testShallow() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); |