aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files')
-rw-r--r--tests/lib/Files/Cache/CacheTest.php160
-rw-r--r--tests/lib/Files/Cache/HomeCacheTest.php20
-rw-r--r--tests/lib/Files/Cache/MoveFromCacheTraitTest.php4
-rw-r--r--tests/lib/Files/Cache/ScannerTest.php8
-rw-r--r--tests/lib/Files/Cache/UpdaterLegacyTest.php19
-rw-r--r--tests/lib/Files/Cache/UpdaterTest.php11
-rw-r--r--tests/lib/Files/Cache/WatcherTest.php26
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php12
-rw-r--r--tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php16
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php16
-rw-r--r--tests/lib/Files/EtagTest.php5
-rw-r--r--tests/lib/Files/FileInfoTest.php2
-rw-r--r--tests/lib/Files/FilesystemTest.php76
-rw-r--r--tests/lib/Files/Mount/ManagerTest.php18
-rw-r--r--tests/lib/Files/Mount/MountPointTest.php4
-rw-r--r--tests/lib/Files/Mount/MountTest.php4
-rw-r--r--tests/lib/Files/Node/FileTest.php32
-rw-r--r--tests/lib/Files/Node/FolderTest.php183
-rw-r--r--tests/lib/Files/Node/IntegrationTest.php4
-rw-r--r--tests/lib/Files/Node/NodeTest.php139
-rw-r--r--tests/lib/Files/Node/RootTest.php6
-rw-r--r--tests/lib/Files/ObjectStore/NoopScannerTest.php2
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php1
-rw-r--r--tests/lib/Files/ObjectStore/S3Test.php8
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFileTest.php1
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFolderTest.php3
-rw-r--r--tests/lib/Files/Storage/HomeTest.php2
-rw-r--r--tests/lib/Files/Storage/LocalTest.php2
-rw-r--r--tests/lib/Files/Storage/Storage.php30
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php58
-rw-r--r--tests/lib/Files/Storage/Wrapper/JailTest.php10
-rw-r--r--tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php10
-rw-r--r--tests/lib/Files/Storage/Wrapper/QuotaTest.php30
-rw-r--r--tests/lib/Files/Storage/Wrapper/WrapperTest.php4
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php12
-rw-r--r--tests/lib/Files/Type/DetectionTest.php8
-rw-r--r--tests/lib/Files/Utils/ScannerTest.php20
-rw-r--r--tests/lib/Files/ViewTest.php88
38 files changed, 529 insertions, 525 deletions
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index b2816c03094..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));
}
/**
@@ -544,9 +544,9 @@ class CacheTest extends \Test\TestCase {
$cacheMock->expects($this->any())
->method('normalize')
- ->will($this->returnArgument(0));
+ ->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..02cb6d79eb1 100644
--- a/tests/lib/Files/Cache/UpdaterLegacyTest.php
+++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php
@@ -9,7 +9,6 @@
namespace Test\Files\Cache;
use OC\Files\Filesystem as Filesystem;
-use OC\Files\Storage\Temporary;
use OC\Files\View;
/**
@@ -40,7 +39,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 +62,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 +84,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 +117,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 +178,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 +234,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..4c99b24d9d6 100644
--- a/tests/lib/Files/Cache/UpdaterTest.php
+++ b/tests/lib/Files/Cache/UpdaterTest.php
@@ -10,7 +10,6 @@ namespace Test\Files\Cache;
use OC\Files\Filesystem;
use OC\Files\Storage\Temporary;
-use OC\Files\View;
/**
* Class UpdaterTest
@@ -45,7 +44,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 +219,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 +250,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/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index 2f61f634ffb..6f347a504cb 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -77,24 +77,24 @@ class UserMountCacheTest extends TestCase {
->getMock();
$storageCache->expects($this->any())
->method('getNumericId')
- ->will($this->returnValue($storageId));
+ ->willReturn($storageId);
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
->disableOriginalConstructor()
->getMock();
$cache->expects($this->any())
->method('getId')
- ->will($this->returnValue($rootId));
+ ->willReturn($rootId);
$storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
->disableOriginalConstructor()
->getMock();
$storage->expects($this->any())
->method('getStorageCache')
- ->will($this->returnValue($storageCache));
+ ->willReturn($storageCache);
$storage->expects($this->any())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
return [$storage, $rootId];
}
@@ -401,7 +401,7 @@ class UserMountCacheTest extends TestCase {
$mount1->expects($this->any())
->method('getStorageRootId')
- ->will($this->returnValue($folderId));
+ ->willReturn($folderId);
$this->cache->registerMounts($user1, [$mount1]);
@@ -434,7 +434,7 @@ class UserMountCacheTest extends TestCase {
$mount1->expects($this->any())
->method('getStorageRootId')
- ->will($this->returnValue($folderId));
+ ->willReturn($folderId);
$this->cache->registerMounts($user1, [$mount1]);
@@ -481,11 +481,11 @@ class UserMountCacheTest extends TestCase {
$mount1->expects($this->any())
->method('getStorageRootId')
- ->will($this->returnValue($rootId));
+ ->willReturn($rootId);
$mount1->expects($this->any())
->method('getNumericStorageId')
- ->will($this->returnValue(2));
+ ->willReturn(2);
$this->cache->registerMounts($user1, [$mount1]);
diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php
index d3b372fe137..39069ce4dfe 100644
--- a/tests/lib/Files/EtagTest.php
+++ b/tests/lib/Files/EtagTest.php
@@ -10,7 +10,6 @@ namespace Test\Files;
use OC\Files\Filesystem;
use OCP\EventDispatcher\IEventDispatcher;
-use OCP\Share;
use OCA\Files_Sharing\AppInfo\Application;
/**
@@ -67,7 +66,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 +83,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/FileInfoTest.php b/tests/lib/Files/FileInfoTest.php
index 0037941b629..fd2b506beb9 100644
--- a/tests/lib/Files/FileInfoTest.php
+++ b/tests/lib/Files/FileInfoTest.php
@@ -8,11 +8,9 @@
namespace Test\Files;
-use OC\AllConfig;
use OC\Files\FileInfo;
use OC\Files\Storage\Home;
use OC\Files\Storage\Temporary;
-use OC\User\User;
use OCP\IConfig;
use OCP\IUser;
use Test\TestCase;
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/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php
index 9b63c507b5f..800b360415a 100644
--- a/tests/lib/Files/Mount/MountPointTest.php
+++ b/tests/lib/Files/Mount/MountPointTest.php
@@ -21,12 +21,12 @@ class MountPointTest extends \Test\TestCase {
$storage = $this->createMock(Storage::class);
$storage->expects($this->once())
->method('getId')
- ->will($this->returnValue(123));
+ ->willReturn(123);
$loader = $this->createMock(StorageFactory::class);
$loader->expects($this->once())
->method('wrap')
- ->will($this->returnValue($storage));
+ ->willReturn($storage);
$mountPoint = new \OC\Files\Mount\MountPoint(
// just use this because a real class is needed
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 2cdf9cbdc5a..c6f468b796b 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -48,12 +48,12 @@ class FileTest extends NodeTest {
$this->view->expects($this->once())
->method('file_get_contents')
->with('/bar/foo')
- ->will($this->returnValue('bar'));
+ ->willReturn('bar');
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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());
@@ -70,12 +70,12 @@ class FileTest extends NodeTest {
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($this->getFileInfo(array('permissions' => 0))));
+ ->willReturn($this->getFileInfo(['permissions' => 0]));
$node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
$node->getContent();
@@ -89,17 +89,17 @@ class FileTest extends NodeTest {
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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')
->with('/bar/foo', 'bar')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
$node->putContent('bar');
@@ -117,7 +117,7 @@ class FileTest extends NodeTest {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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')
- ->will($this->returnValue($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());
@@ -162,12 +162,12 @@ class FileTest extends NodeTest {
$this->view->expects($this->once())
->method('fopen')
->with('/bar/foo', 'r')
- ->will($this->returnValue($stream));
+ ->willReturn($stream);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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');
@@ -197,12 +197,12 @@ class FileTest extends NodeTest {
$this->view->expects($this->once())
->method('fopen')
->with('/bar/foo', 'w')
- ->will($this->returnValue($stream));
+ ->willReturn($stream);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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')
- ->will($this->returnValue($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')
- ->will($this->returnValue($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')
- ->will($this->returnValue($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 d33fb4f68f8..d2bbf65965a 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -19,7 +19,6 @@ use OC\Files\Node\Root;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Jail;
use OC\Files\View;
-use OC\User\User;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\Storage;
@@ -59,15 +58,15 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$view->expects($this->any())
->method('getDirectoryContent')
->with('/bar/foo')
- ->will($this->returnValue(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();
@@ -91,7 +90,7 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$root->expects($this->once())
->method('get')
@@ -112,14 +111,14 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$child = new \OC\Files\Node\Folder($root, $view, '/bar/foo/asd');
$root->expects($this->once())
->method('get')
->with('/bar/foo/asd')
- ->will($this->returnValue($child));
+ ->willReturn($child);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$this->assertTrue($node->nodeExists('asd'));
@@ -136,7 +135,7 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$root->expects($this->once())
->method('get')
@@ -158,17 +157,17 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
$view->expects($this->once())
->method('mkdir')
->with('/bar/foo/asd')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$child = new \OC\Files\Node\Folder($root, $view, '/bar/foo/asd');
@@ -190,12 +189,12 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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');
@@ -212,17 +211,17 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL))));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
$view->expects($this->once())
->method('touch')
->with('/bar/foo/asd')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$child = new \OC\Files\Node\File($root, $view, '/bar/foo/asd');
@@ -244,12 +243,12 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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');
@@ -266,12 +265,12 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$view->expects($this->once())
->method('free_space')
->with('/bar/foo')
- ->will($this->returnValue(100));
+ ->willReturn(100);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$this->assertEquals(100, $node->getFreeSpace());
@@ -288,39 +287,39 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$storage = $this->createMock(Storage::class);
$storage->method('getId')->willReturn('');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$mount = $this->createMock(IMountPoint::class);
$mount->expects($this->once())
->method('getStorage')
- ->will($this->returnValue($storage));
+ ->willReturn($storage);
$mount->expects($this->once())
->method('getInternalPath')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$cache->expects($this->once())
->method('search')
->with('%qw%')
- ->will($this->returnValue(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')
- ->will($this->returnValue(array()));
+ ->willReturn([]);
$root->expects($this->once())
->method('getMount')
->with('/bar/foo')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$result = $node->search('qw');
@@ -340,7 +339,7 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
/** @var \PHPUnit_Framework_MockObject_MockObject|Storage $storage */
$storage = $this->createMock(Storage::class);
$storage->method('getId')->willReturn('');
@@ -349,32 +348,32 @@ class FolderTest extends NodeTest {
$mount = $this->createMock(IMountPoint::class);
$mount->expects($this->once())
->method('getStorage')
- ->will($this->returnValue($storage));
+ ->willReturn($storage);
$mount->expects($this->once())
->method('getInternalPath')
- ->will($this->returnValue('files'));
+ ->willReturn('files');
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$cache->expects($this->once())
->method('search')
->with('%qw%')
- ->will($this->returnValue(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('')
- ->will($this->returnValue(array()));
+ ->willReturn([]);
$root->expects($this->once())
->method('getMount')
->with('')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$result = $root->search('qw');
$this->assertEquals(1, count($result));
@@ -392,7 +391,7 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$storage = $this->createMock(Storage::class);
$storage->method('getId')->willReturn('');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
@@ -400,31 +399,31 @@ class FolderTest extends NodeTest {
$mount = $this->createMock(IMountPoint::class);
$mount->expects($this->once())
->method('getStorage')
- ->will($this->returnValue($storage));
+ ->willReturn($storage);
$mount->expects($this->once())
->method('getInternalPath')
- ->will($this->returnValue(''));
+ ->willReturn('');
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$cache->expects($this->once())
->method('search')
->with('%qw%')
- ->will($this->returnValue(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')
- ->will($this->returnValue(array()));
+ ->willReturn([]);
$root->expects($this->once())
->method('getMount')
->with('/bar')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$node = new \OC\Files\Node\Folder($root, $view, '/bar');
$result = $node->search('qw');
@@ -443,7 +442,7 @@ class FolderTest extends NodeTest {
->getMock();
$root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$storage = $this->createMock(Storage::class);
$storage->method('getId')->willReturn('');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
@@ -454,50 +453,50 @@ class FolderTest extends NodeTest {
$mount = $this->createMock(IMountPoint::class);
$mount->expects($this->once())
->method('getStorage')
- ->will($this->returnValue($storage));
+ ->willReturn($storage);
$mount->expects($this->once())
->method('getInternalPath')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$subMount->expects($this->once())
->method('getStorage')
- ->will($this->returnValue($subStorage));
+ ->willReturn($subStorage);
$subMount->expects($this->once())
->method('getMountPoint')
- ->will($this->returnValue('/bar/foo/bar/'));
+ ->willReturn('/bar/foo/bar/');
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$subStorage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($subCache));
+ ->willReturn($subCache);
$cache->expects($this->once())
->method('search')
->with('%qw%')
- ->will($this->returnValue(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%')
- ->will($this->returnValue(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')
- ->will($this->returnValue(array($subMount)));
+ ->willReturn([$subMount]);
$root->expects($this->once())
->method('getMount')
->with('/bar/foo')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
@@ -534,34 +533,34 @@ class FolderTest extends NodeTest {
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$this->userMountCache->expects($this->any())
->method('getMountsForFileId')
->with(1)
- ->will($this->returnValue([new CachedMountInfo(
+ ->willReturn([new CachedMountInfo(
$this->user,
1,
0,
'/bar/',
1,
''
- )]));
+ )]);
$cache->expects($this->once())
->method('get')
->with(1)
- ->will($this->returnValue($fileInfo));
+ ->willReturn($fileInfo);
$root->expects($this->once())
->method('getMountsIn')
->with('/bar/foo')
- ->will($this->returnValue(array()));
+ ->willReturn([]);
$root->expects($this->once())
->method('getMount')
->with('/bar/foo')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$result = $node->getById(1);
@@ -588,29 +587,29 @@ class FolderTest extends NodeTest {
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$this->userMountCache->expects($this->any())
->method('getMountsForFileId')
->with(1)
- ->will($this->returnValue([new CachedMountInfo(
+ ->willReturn([new CachedMountInfo(
$this->user,
1,
0,
'/bar/',
1,
''
- )]));
+ )]);
$cache->expects($this->once())
->method('get')
->with(1)
- ->will($this->returnValue($fileInfo));
+ ->willReturn($fileInfo);
$root->expects($this->once())
->method('getMount')
->with('/bar')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$node = new \OC\Files\Node\Folder($root, $view, '/bar');
$result = $node->getById(1);
@@ -637,34 +636,34 @@ class FolderTest extends NodeTest {
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$this->userMountCache->expects($this->any())
->method('getMountsForFileId')
->with(1)
- ->will($this->returnValue([new CachedMountInfo(
+ ->willReturn([new CachedMountInfo(
$this->user,
1,
0,
'/bar/',
1,
''
- )]));
+ )]);
$cache->expects($this->once())
->method('get')
->with(1)
- ->will($this->returnValue($fileInfo));
+ ->willReturn($fileInfo);
$root->expects($this->once())
->method('getMountsIn')
->with('/bar/foo')
- ->will($this->returnValue(array()));
+ ->willReturn([]);
$root->expects($this->once())
->method('getMount')
->with('/bar/foo')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$result = $node->getById(1);
@@ -691,12 +690,12 @@ class FolderTest extends NodeTest {
$storage->expects($this->exactly(2))
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$this->userMountCache->expects($this->any())
->method('getMountsForFileId')
->with(1)
- ->will($this->returnValue([
+ ->willReturn([
new CachedMountInfo(
$this->user,
1,
@@ -713,26 +712,26 @@ class FolderTest extends NodeTest {
1,
''
)
- ]));
+ ]);
$storage->expects($this->any())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$cache->expects($this->any())
->method('get')
->with(1)
- ->will($this->returnValue($fileInfo));
+ ->willReturn($fileInfo);
$root->expects($this->any())
->method('getMountsIn')
->with('/bar/foo')
- ->will($this->returnValue(array($mount2)));
+ ->willReturn([$mount2]);
$root->expects($this->once())
->method('getMount')
->with('/bar/foo')
- ->will($this->returnValue($mount1));
+ ->willReturn($mount1);
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$result = $node->getById(1);
@@ -767,14 +766,14 @@ class FolderTest extends NodeTest {
$view->expects($this->any())
->method('file_exists')
- ->will($this->returnCallback(function ($path) use ($existingFiles, $folderPath) {
+ ->willReturnCallback(function ($path) use ($existingFiles, $folderPath) {
foreach ($existingFiles as $existing) {
if ($folderPath . '/' . $existing === $path) {
return true;
}
}
return false;
- }));
+ });
$node = new \OC\Files\Node\Folder($root, $view, $folderPath);
$this->assertEquals($expected, $node->getNonExistingName($name));
@@ -802,7 +801,7 @@ class FolderTest extends NodeTest {
$folderInfo->expects($this->any())
->method('getMountPoint')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$cache = $storage->getCache();
@@ -866,7 +865,7 @@ class FolderTest extends NodeTest {
$folderInfo->expects($this->any())
->method('getMountPoint')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$cache = $storage->getCache();
@@ -932,7 +931,7 @@ class FolderTest extends NodeTest {
$folderInfo->expects($this->any())
->method('getMountPoint')
- ->will($this->returnValue($mount));
+ ->willReturn($mount);
$cache = $storage->getCache();
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 7c8ddee6b5f..adcf43956be 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -11,14 +11,11 @@ namespace Test\Files\Node;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\View;
-use OCP\Files\Config\IUserMountCache;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\Storage;
-use OCP\IConfig;
use OCP\ILogger;
-use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
@@ -92,7 +89,7 @@ abstract class NodeTest extends \Test\TestCase {
->getMock();
$storage->expects($this->any())
->method('getId')
- ->will($this->returnValue('home::someuser'));
+ ->willReturn('home::someuser');
return $storage;
}
@@ -103,20 +100,20 @@ abstract class NodeTest extends \Test\TestCase {
public function testDelete() {
$this->root->expects($this->exactly(2))
->method('emit')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
$this->view->expects($this->once())
->method($this->getViewDeleteMethod())
->with('/bar/foo')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$node->delete();
@@ -163,17 +160,17 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1, 'mimetype' => 'text/plain'])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1, 'mimetype' => 'text/plain']));
$this->view->expects($this->once())
->method($this->getViewDeleteMethod())
->with('/bar/foo')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->view->expects($this->any())
->method('resolvePath')
->with('/bar/foo')
- ->will($this->returnValue([null, 'foo']));
+ ->willReturn([null, 'foo']);
$node = $this->createTestNode($root, $this->view, '/bar/foo');
$node->delete();
@@ -186,12 +183,12 @@ abstract class NodeTest extends \Test\TestCase {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$node->delete();
@@ -201,20 +198,20 @@ abstract class NodeTest extends \Test\TestCase {
public function testStat() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
- $stat = array(
+ $stat = [
'fileid' => 1,
'size' => 100,
'etag' => 'qwerty',
'mtime' => 50,
'permissions' => 0
- );
+ ];
$this->view->expects($this->once())
->method('stat')
->with('/bar/foo')
- ->will($this->returnValue($stat));
+ ->willReturn($stat);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals($stat, $node->stat());
@@ -223,19 +220,19 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetId() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->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')
->with('/bar/foo')
- ->will($this->returnValue($stat));
+ ->willReturn($stat);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals(1, $node->getId());
@@ -244,20 +241,20 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetSize() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->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')
->with('/bar/foo')
- ->will($this->returnValue($stat));
+ ->willReturn($stat);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals(100, $node->getSize());
@@ -266,19 +263,19 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetEtag() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->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')
->with('/bar/foo')
- ->will($this->returnValue($stat));
+ ->willReturn($stat);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals('qwerty', $node->getEtag());
@@ -287,19 +284,19 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetMTime() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->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')
->with('/bar/foo')
- ->will($this->returnValue($stat));
+ ->willReturn($stat);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals(50, $node->getMTime());
@@ -308,7 +305,7 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetStorage() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
/**
* @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage
*/
@@ -319,7 +316,7 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->once())
->method('resolvePath')
->with('/bar/foo')
- ->will($this->returnValue(array($storage, 'foo')));
+ ->willReturn([$storage, 'foo']);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
@@ -329,7 +326,7 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetPath() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals('/bar/foo', $node->getPath());
@@ -338,7 +335,7 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetInternalPath() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
/**
* @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage
*/
@@ -349,7 +346,7 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->once())
->method('resolvePath')
->with('/bar/foo')
- ->will($this->returnValue(array($storage, 'foo')));
+ ->willReturn([$storage, 'foo']);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
@@ -359,7 +356,7 @@ abstract class NodeTest extends \Test\TestCase {
public function testGetName() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$this->assertEquals('foo', $node->getName());
@@ -368,17 +365,17 @@ abstract class NodeTest extends \Test\TestCase {
public function testTouchSetMTime() {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->view->expects($this->once())
->method('touch')
->with('/bar/foo', 100)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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);
@@ -420,17 +417,17 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->once())
->method('touch')
->with('/bar/foo', 100)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->view->expects($this->any())
->method('resolvePath')
->with('/bar/foo')
- ->will($this->returnValue(array(null, 'foo')));
+ ->willReturn([null, 'foo']);
$this->view->expects($this->any())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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);
@@ -443,12 +440,12 @@ abstract class NodeTest extends \Test\TestCase {
$this->root->expects($this->any())
->method('getUser')
- ->will($this->returnValue($this->user));
+ ->willReturn($this->user);
$this->view->expects($this->any())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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);
@@ -466,11 +463,11 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('copy')
->with('/bar/foo', '/bar/asd')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
@@ -478,10 +475,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->root->expects($this->exactly(2))
->method('get')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['/bar/asd', $newNode],
['/bar', $parentNode]
- ]));
+ ]);
$target = $node->copy('/bar/asd');
$this->assertInstanceOf($this->getNodeClass(), $target);
@@ -505,16 +502,16 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
$this->root->expects($this->once())
->method('get')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['/bar', $parentNode]
- ]));
+ ]);
$node->copy('/bar/asd');
}
@@ -548,9 +545,9 @@ abstract class NodeTest extends \Test\TestCase {
$this->root->expects($this->once())
->method('get')
- ->will($this->returnValueMap([
+ ->willReturnMap([
['/bar', $parentNode]
- ]));
+ ]);
$node->copy('/bar/asd');
}
@@ -559,18 +556,18 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('rename')
->with('/bar/foo', '/bar/asd')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
$this->root->expects($this->any())
->method('get')
- ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]]));
+ ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $node]]);
$target = $node->move('/bar/asd');
$this->assertInstanceOf($this->getNodeClass(), $target);
@@ -602,11 +599,11 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method($viewMethod)
->with('/bar/foo', '/bar/asd')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
/**
* @var \OC\Files\Node\File|\PHPUnit_Framework_MockObject_MockObject $node
@@ -617,7 +614,7 @@ abstract class NodeTest extends \Test\TestCase {
$root->expects($this->any())
->method('get')
- ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $targetTestNode]]));
+ ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $targetTestNode]]);
$hooksRun = 0;
@@ -665,7 +662,7 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
$this->view->expects($this->never())
->method('rename');
@@ -676,7 +673,7 @@ abstract class NodeTest extends \Test\TestCase {
$this->root->expects($this->once())
->method('get')
->with('/bar')
- ->will($this->returnValue($parentNode));
+ ->willReturn($parentNode);
$node->move('/bar/asd');
}
@@ -716,7 +713,7 @@ abstract class NodeTest extends \Test\TestCase {
$this->root->expects($this->once())
->method('get')
->with('/bar')
- ->will($this->returnValue($parentNode));
+ ->willReturn($parentNode);
$node->move('/bar/asd');
}
@@ -728,18 +725,18 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('rename')
->with('/bar/foo', '/bar/asd')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
$this->root->expects($this->any())
->method('get')
- ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]]));
+ ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $node]]);
$node->move('/bar/asd');
}
@@ -751,18 +748,18 @@ abstract class NodeTest extends \Test\TestCase {
$this->view->expects($this->any())
->method('copy')
->with('/bar/foo', '/bar/asd')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->view->expects($this->any())
->method('getFileInfo')
- ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])));
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
$this->root->expects($this->any())
->method('get')
- ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]]));
+ ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $node]]);
$node->copy('/bar/asd');
}
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index 5067236ec58..6c006d1cf62 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -13,9 +13,7 @@ use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Node\Folder;
use OC\Files\View;
-use OCP\IConfig;
use OCP\ILogger;
-use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
@@ -79,7 +77,7 @@ class RootTest extends \Test\TestCase {
$view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue($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');
@@ -115,7 +113,7 @@ class RootTest extends \Test\TestCase {
$view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$root->mount($storage, '');
$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/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
index b8c7b15e039..25ce5525361 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
@@ -20,7 +20,6 @@
namespace Test\Files\ObjectStore;
-use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\ObjectStore\StorageObjectStore;
use OC\Files\Storage\Temporary;
use OCP\Files\ObjectStore\IObjectStore;
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/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php
index 07a7e79c7a3..8de5cf50aa3 100644
--- a/tests/lib/Files/SimpleFS/SimpleFileTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php
@@ -27,7 +27,6 @@ use OC\Files\SimpleFS\SimpleFile;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
-use OCP\Files\NotPermittedException;
class SimpleFileTest extends \Test\TestCase {
/** @var File|\PHPUnit_Framework_MockObject_MockObject */
diff --git a/tests/lib/Files/SimpleFS/SimpleFolderTest.php b/tests/lib/Files/SimpleFS/SimpleFolderTest.php
index b902cac77cc..4cab1136d82 100644
--- a/tests/lib/Files/SimpleFS/SimpleFolderTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFolderTest.php
@@ -25,10 +25,7 @@ namespace Test\File\SimpleFS;
use OC\Files\SimpleFS\SimpleFolder;
use OC\Files\Storage\Temporary;
-use OC\Files\View;
-use OCP\Files\File;
use OCP\Files\Folder;
-use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use Test\Traits\MountProviderTrait;
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 0061ca3910e..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(''));
}
@@ -82,12 +82,12 @@ class QuotaTest extends \Test\Files\Storage\Storage {
->getMock();
$storage->expects($this->any())
->method('free_space')
- ->will($this->returnValue(-2));
+ ->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(''));
}
@@ -138,9 +138,9 @@ class QuotaTest extends \Test\Files\Storage\Storage {
->getMock();
$failStorage->expects($this->any())
->method('fopen')
- ->will($this->returnValue(false));
+ ->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'));
}
@@ -189,16 +189,16 @@ class QuotaTest extends \Test\Files\Storage\Storage {
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')->disableOriginalConstructor()->getMock();
$storage->expects($this->once())
->method('getCache')
- ->will($this->returnValue($cache));
+ ->willReturn($cache);
$storage->expects($this->once())
->method('free_space')
- ->will($this->returnValue(2048));
+ ->willReturn(2048);
$cache->expects($this->once())
->method('get')
->with('files')
- ->will($this->returnValue(new CacheEntry(['size' => 50])));
+ ->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 fd5e8c6ca9d..43114ff70f3 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -99,10 +99,10 @@ class EncryptionTest extends \Test\TestCase {
$fileMock->expects($this->never())->method('getAccessList');
} else {
$fileMock->expects($this->once())->method('getAccessList')
- ->will($this->returnCallback(function ($sharePath) use ($expectedSharePath) {
+ ->willReturnCallback(function ($sharePath) use ($expectedSharePath) {
$this->assertSame($expectedSharePath, $sharePath);
- return array();
- }));
+ return [];
+ });
}
$utilMock = $this->getMockBuilder('\OC\Encryption\Util')
->disableOriginalConstructor()->getMock();
@@ -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]);
@@ -205,9 +205,9 @@ class EncryptionTest extends \Test\TestCase {
$fileName = tempnam("/tmp", "FOO");
$stream = $this->getStream($fileName, 'w+', 0);
$this->assertEquals(6, fwrite($stream, 'foobar'));
- $this->assertEquals(TRUE, rewind($stream));
+ $this->assertEquals(true, rewind($stream));
$this->assertEquals('foobar', fread($stream, 100));
- $this->assertEquals(TRUE, rewind($stream));
+ $this->assertEquals(true, rewind($stream));
$this->assertEquals(3, fwrite($stream, 'bar'));
fclose($stream);
diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php
index 01f11bf39c8..3befe64c825 100644
--- a/tests/lib/Files/Type/DetectionTest.php
+++ b/tests/lib/Files/Type/DetectionTest.php
@@ -240,14 +240,14 @@ class DetectionTest extends \Test\TestCase {
[$this->equalTo('core'), $this->equalTo('filetypes/my-type.png')],
[$this->equalTo('core'), $this->equalTo('filetypes/my.png')]
)
- ->will($this->returnCallback(
+ ->willReturnCallback(
function($appName, $file) {
if ($file === 'filetypes/my.png') {
return 'my.svg';
}
throw new \RuntimeException();
}
- ));
+ );
$detection = new Detection($urlGenerator, $logger, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('my-type');
@@ -271,14 +271,14 @@ class DetectionTest extends \Test\TestCase {
[$this->equalTo('core'), $this->equalTo('filetypes/foo.png')],
[$this->equalTo('core'), $this->equalTo('filetypes/file.png')]
)
- ->will($this->returnCallback(
+ ->willReturnCallback(
function($appName, $file) {
if ($file === 'filetypes/file.png') {
return 'file.svg';
}
throw new \RuntimeException();
}
- ));
+ );
$detection = new Detection($urlGenerator, $logger, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('foo-bar');
diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php
index 44422cd97d1..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,18 +112,18 @@ 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())
->method('getMountsForUser')
- ->will($this->returnCallback(function (IUser $user, IStorageFactory $storageFactory) use ($mount, $uid) {
+ ->willReturnCallback(function (IUser $user, IStorageFactory $storageFactory) use ($mount, $uid) {
if ($user->getUID() === $uid) {
return [$mount];
} else {
return [];
}
- }));
+ });
\OC::$server->getMountProviderCollection()->registerProvider($mountProvider);
$cache = $storage->getCache();
@@ -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();
@@ -199,9 +199,9 @@ class ScannerTest extends \Test\TestCase {
$sharedStorage->expects($this->any())
->method('instanceOfStorage')
- ->will($this->returnValueMap([
+ ->willReturnMap([
[SharedStorage::class, true],
- ]));
+ ]);
$sharedStorage->expects($this->never())
->method('getScanner');
@@ -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();
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 57050059375..c1da385a3cc 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -15,6 +15,7 @@ use OC\Files\Storage\Common;
use OC\Files\Storage\Temporary;
use OC\Files\Stream\Quota;
use OC\Files\View;
+use OCP\Constants;
use OCP\Files\Config\IMountProvider;
use OCP\Files\FileInfo;
use OCP\Files\Storage\IStorage;
@@ -1169,11 +1170,11 @@ class ViewTest extends \Test\TestCase {
$storage2->expects($this->any())
->method('fopen')
- ->will($this->returnCallback(function ($path, $mode) use ($storage2) {
+ ->willReturnCallback(function ($path, $mode) use ($storage2) {
/** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Files\Storage\Temporary $storage2 */
$source = fopen($storage2->getSourcePath($path), $mode);
return Quota::wrap($source, 9);
- }));
+ });
$storage1->mkdir('sub');
$storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH');
@@ -1220,7 +1221,7 @@ class ViewTest extends \Test\TestCase {
->getMock();
$storage->expects($this->once())
->method('unlink')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$scanner = $storage->getScanner();
$cache = $storage->getCache();
$storage->file_put_contents('foo.txt', 'asd');
@@ -1597,7 +1598,7 @@ class ViewTest extends \Test\TestCase {
$mountProvider = $this->createMock(IMountProvider::class);
$mountProvider->expects($this->any())
->method('getMountsForUser')
- ->will($this->returnValue($mounts));
+ ->willReturn($mounts);
$mountProviderCollection = \OC::$server->getMountProviderCollection();
$mountProviderCollection->registerProvider($mountProvider);
@@ -1611,17 +1612,17 @@ class ViewTest extends \Test\TestCase {
public function testMountPointMove() {
self::loginAsUser($this->user);
- list($mount1, $mount2) = $this->createTestMovableMountPoints([
+ [$mount1, $mount2] = $this->createTestMovableMountPoints([
$this->user . '/files/mount1',
$this->user . '/files/mount2',
]);
$mount1->expects($this->once())
->method('moveMount')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$mount2->expects($this->once())
->method('moveMount')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$view = new View('/' . $this->user . '/files/');
$view->mkdir('sub');
@@ -1636,7 +1637,7 @@ class ViewTest extends \Test\TestCase {
public function testMoveMountPointIntoAnother() {
self::loginAsUser($this->user);
- list($mount1, $mount2) = $this->createTestMovableMountPoints([
+ [$mount1, $mount2] = $this->createTestMovableMountPoints([
$this->user . '/files/mount1',
$this->user . '/files/mount2',
]);
@@ -1659,7 +1660,7 @@ class ViewTest extends \Test\TestCase {
public function testMoveMountPointIntoSharedFolder() {
self::loginAsUser($this->user);
- list($mount1) = $this->createTestMovableMountPoints([
+ [$mount1] = $this->createTestMovableMountPoints([
$this->user . '/files/mount1',
]);
@@ -1846,13 +1847,13 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->once())
->method($operation)
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $lockedPath, &$lockTypeDuring) {
$lockTypeDuring = $this->getFileLockType($view, $lockedPath);
return true;
}
- ));
+ );
$this->assertNull($this->getFileLockType($view, $lockedPath), 'File not locked before operation');
@@ -1890,13 +1891,13 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->once())
->method('fopen')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $path, &$lockTypeDuring) {
$lockTypeDuring = $this->getFileLockType($view, $path);
return fopen('php://temp', 'r+');
}
- ));
+ );
$this->connectMockHooks('write', $view, $path, $lockTypePre, $lockTypePost);
@@ -1929,13 +1930,13 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->once())
->method('fopen')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $path, &$lockTypeDuring) {
$lockTypeDuring = $this->getFileLockType($view, $path);
return fopen('php://temp', 'r+');
}
- ));
+ );
$this->connectMockHooks('write', $view, $path, $lockTypePre, $lockTypePost);
@@ -1990,11 +1991,11 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->once())
->method($operation)
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () {
throw new \Exception('Simulated exception');
}
- ));
+ );
$thrown = false;
try {
@@ -2097,12 +2098,21 @@ class ViewTest extends \Test\TestCase {
/** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage */
$storage = $this->getMockBuilder(Temporary::class)
- ->setMethods([$operation, 'filemtime'])
+ ->setMethods([$operation, 'getMetaData', 'filemtime'])
->getMock();
$storage->expects($this->any())
+ ->method('getMetaData')
+ ->will($this->returnValue([
+ 'mtime' => 1885434487,
+ 'etag' => '',
+ 'mimetype' => 'text/plain',
+ 'permissions' => Constants::PERMISSION_ALL,
+ 'size' => 3
+ ]));
+ $storage->expects($this->any())
->method('filemtime')
- ->will($this->returnValue(123456789));
+ ->willReturn(123456789);
$sourcePath = 'original.txt';
$targetPath = 'target.txt';
@@ -2113,14 +2123,14 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->once())
->method($operation)
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $sourcePath, $targetPath, &$lockTypeSourceDuring, &$lockTypeTargetDuring) {
$lockTypeSourceDuring = $this->getFileLockType($view, $sourcePath);
$lockTypeTargetDuring = $this->getFileLockType($view, $targetPath);
return true;
}
- ));
+ );
$this->connectMockHooks($operation, $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost);
$this->connectMockHooks($operation, $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost);
@@ -2166,11 +2176,11 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->once())
->method('copy')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () {
throw new \Exception();
}
- ));
+ );
$this->connectMockHooks('copy', $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost);
$this->connectMockHooks('copy', $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost);
@@ -2277,12 +2287,21 @@ class ViewTest extends \Test\TestCase {
->getMock();
/** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage2 */
$storage2 = $this->getMockBuilder(Temporary::class)
- ->setMethods([$storageOperation, 'filemtime'])
+ ->setMethods([$storageOperation, 'getMetaData', 'filemtime'])
->getMock();
$storage2->expects($this->any())
+ ->method('getMetaData')
+ ->will($this->returnValue([
+ 'mtime' => 1885434487,
+ 'etag' => '',
+ 'mimetype' => 'text/plain',
+ 'permissions' => Constants::PERMISSION_ALL,
+ 'size' => 3
+ ]));
+ $storage2->expects($this->any())
->method('filemtime')
- ->will($this->returnValue(123456789));
+ ->willReturn(123456789);
$sourcePath = 'original.txt';
$targetPath = 'substorage/target.txt';
@@ -2296,14 +2315,14 @@ class ViewTest extends \Test\TestCase {
->method($storageOperation);
$storage2->expects($this->once())
->method($storageOperation)
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $sourcePath, $targetPath, &$lockTypeSourceDuring, &$lockTypeTargetDuring) {
$lockTypeSourceDuring = $this->getFileLockType($view, $sourcePath);
$lockTypeTargetDuring = $this->getFileLockType($view, $targetPath);
return true;
}
- ));
+ );
$this->connectMockHooks($viewOperation, $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost);
$this->connectMockHooks($viewOperation, $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost);
@@ -2331,7 +2350,7 @@ class ViewTest extends \Test\TestCase {
public function testLockMoveMountPoint() {
self::loginAsUser('test');
- list($mount) = $this->createTestMovableMountPoints([
+ [$mount] = $this->createTestMovableMountPoints([
$this->user . '/files/substorage',
]);
@@ -2343,7 +2362,7 @@ class ViewTest extends \Test\TestCase {
$mount->expects($this->once())
->method('moveMount')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function ($target) use ($mount, $view, $sourcePath, $targetPath, &$lockTypeSourceDuring, &$lockTypeTargetDuring, &$lockTypeSharedRootDuring) {
$lockTypeSourceDuring = $this->getFileLockType($view, $sourcePath, true);
$lockTypeTargetDuring = $this->getFileLockType($view, $targetPath, true);
@@ -2354,7 +2373,7 @@ class ViewTest extends \Test\TestCase {
return true;
}
- ));
+ );
$this->connectMockHooks('rename', $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost, true);
$this->connectMockHooks('rename', $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost, true);
@@ -2408,18 +2427,18 @@ class ViewTest extends \Test\TestCase {
$eventHandler->expects($this->any())
->method('preCallback')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $path, $onMountPoint, &$lockTypePre) {
$lockTypePre = $this->getFileLockType($view, $path, $onMountPoint);
}
- ));
+ );
$eventHandler->expects($this->any())
->method('postCallback')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () use ($view, $path, $onMountPoint, &$lockTypePost) {
$lockTypePost = $this->getFileLockType($view, $path, $onMountPoint);
}
- ));
+ );
if ($hookType !== null) {
Util::connectHook(
@@ -2553,6 +2572,7 @@ class ViewTest extends \Test\TestCase {
$fh = tmpfile();
fwrite($fh, 'fooo');
rewind($fh);
+ clearstatcache();
$view->file_put_contents('', $fh);
$this->assertEquals('fooo', $view->file_get_contents(''));
$data = $view->getFileInfo('.');