diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /tests/lib/Files | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) | |
download | nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip |
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.
This also removes and empty lines from method/function bodies at the
beginning and end.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Files')
22 files changed, 31 insertions, 51 deletions
diff --git a/tests/lib/Files/AppData/AppDataTest.php b/tests/lib/Files/AppData/AppDataTest.php index 1b3f705b9b6..a03be9e45e9 100644 --- a/tests/lib/Files/AppData/AppDataTest.php +++ b/tests/lib/Files/AppData/AppDataTest.php @@ -108,5 +108,4 @@ class AppDataTest extends \Test\TestCase { $this->assertCount(1, $result); $this->assertInstanceOf(ISimpleFolder::class, $result[0]); } - } diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index dff21491052..f3e61e8e820 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -182,7 +182,6 @@ class CacheTest extends \Test\TestCase { } public function folderDataProvider() { - return [ ['folder'], // that was too easy, try something harder @@ -289,7 +288,6 @@ class CacheTest extends \Test\TestCase { * @param $fileName */ public function testPutWithAllKindOfQuotes($fileName) { - $this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->get($fileName)); $this->cache->put($fileName, ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName]); @@ -573,7 +571,6 @@ class CacheTest extends \Test\TestCase { * this test shows that there is no bug if we use the normalizer */ public function testWithNormalizer() { - if (!class_exists('Patchwork\PHP\Shim\Normalizer')) { $this->markTestSkipped('The 3rdparty Normalizer extension is not available.'); return; diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php index 52f6697cc6d..c51ce0388d5 100644 --- a/tests/lib/Files/Cache/ScannerTest.php +++ b/tests/lib/Files/Cache/ScannerTest.php @@ -406,5 +406,4 @@ class ScannerTest extends \Test\TestCase { ['/sub/folder/foo.txt', false], ]; } - } diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php index 02cb6d79eb1..6d6cc08b3de 100644 --- a/tests/lib/Files/Cache/UpdaterLegacyTest.php +++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php @@ -74,7 +74,9 @@ class UpdaterLegacyTest extends \Test\TestCase { $result = false; $user = \OC::$server->getUserManager()->get(self::$user); - if ($user !== null) { $result = $user->delete(); } + if ($user !== null) { + $result = $user->delete(); + } $this->assertTrue($result); $this->logout(); @@ -304,5 +306,4 @@ class UpdaterLegacyTest extends \Test\TestCase { $this->assertNotSame($rootCachedData['etag'], $cachedData['etag']); $this->assertEquals($time, $cachedData['mtime']); } - } diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php index 5bf998df562..9fc3032fa28 100644 --- a/tests/lib/Files/FilesystemTest.php +++ b/tests/lib/Files/FilesystemTest.php @@ -59,7 +59,6 @@ class DummyMountProvider implements IMountProvider { * @package Test\Files */ class FilesystemTest extends \Test\TestCase { - const TEST_FILESYSTEM_USER1 = "test-filesystem-user1"; const TEST_FILESYSTEM_USER2 = "test-filesystem-user1"; @@ -299,7 +298,6 @@ class FilesystemTest extends \Test\TestCase { $userObj = \OC::$server->getUserManager()->get($user); \OC::$server->getUserSession()->setUser($userObj); \OC\Files\Filesystem::init($user, '/' . $user . '/files'); - } \OC_Hook::clear('OC_Filesystem'); \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); @@ -396,7 +394,9 @@ class FilesystemTest extends \Test\TestCase { } $user = \OC::$server->getUserManager()->get($userId); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } } public function dummyHook($arguments) { @@ -425,7 +425,9 @@ class FilesystemTest extends \Test\TestCase { $this->assertTrue($storage->instanceOfStorage('\OCP\Files\IHomeStorage')); $this->assertEquals('cache', $internalPath); $user = \OC::$server->getUserManager()->get($userId); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } $config->setSystemValue('cache_path', $oldCachePath); } @@ -454,7 +456,9 @@ class FilesystemTest extends \Test\TestCase { $this->assertTrue($storage->instanceOfStorage('\OC\Files\Storage\Local')); $this->assertEquals('', $internalPath); $user = \OC::$server->getUserManager()->get($userId); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } $config->setSystemValue('cache_path', $oldCachePath); } diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php index 976ccc64d70..106a8f9a932 100644 --- a/tests/lib/Files/Mount/MountPointTest.php +++ b/tests/lib/Files/Mount/MountPointTest.php @@ -12,11 +12,9 @@ use OC\Files\Storage\StorageFactory; use OCP\Files\Storage; class DummyStorage { - } class MountPointTest extends \Test\TestCase { - public function testGetStorage() { $storage = $this->createMock(Storage::class); $storage->expects($this->once()) diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php index c6f468b796b..3fa988c89d8 100644 --- a/tests/lib/Files/Node/FileTest.php +++ b/tests/lib/Files/Node/FileTest.php @@ -287,6 +287,4 @@ class FileTest extends NodeTest { $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); } - - } diff --git a/tests/lib/Files/ObjectStore/LocalTest.php b/tests/lib/Files/ObjectStore/LocalTest.php index 99aa23e065d..ceb21428e4b 100644 --- a/tests/lib/Files/ObjectStore/LocalTest.php +++ b/tests/lib/Files/ObjectStore/LocalTest.php @@ -32,5 +32,4 @@ class LocalTest extends ObjectStoreTest { $storage = new Temporary(); return new StorageObjectStore($storage); } - } diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php index 50d3cd553aa..307096d8dbc 100644 --- a/tests/lib/Files/ObjectStore/MapperTest.php +++ b/tests/lib/Files/ObjectStore/MapperTest.php @@ -25,7 +25,6 @@ use OC\Files\ObjectStore\Mapper; use OCP\IUser; class MapperTest extends \Test\TestCase { - public function dataGetBucket() { return [ ['user', 64, '17'], diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php index 25ce5525361..fa8ec535061 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php @@ -56,7 +56,6 @@ class ObjectStoreStorageTest extends Storage { } public function testStat() { - $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $ctimeStart = time(); $this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile)); diff --git a/tests/lib/Files/ObjectStore/ObjectStoreTest.php b/tests/lib/Files/ObjectStore/ObjectStoreTest.php index 67c41eb7ccc..9300a9bdef6 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreTest.php @@ -49,7 +49,6 @@ abstract class ObjectStoreTest extends TestCase { $instance->deleteObject('1'); $this->assertEquals('foobar', stream_get_contents($result)); - } public function testDelete() { diff --git a/tests/lib/Files/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php index 8de5cf50aa3..b9a47c4d6e2 100644 --- a/tests/lib/Files/SimpleFS/SimpleFileTest.php +++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php @@ -28,7 +28,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\NotFoundException; -class SimpleFileTest extends \Test\TestCase { +class SimpleFileTest extends \Test\TestCase { /** @var File|\PHPUnit_Framework_MockObject_MockObject */ private $file; diff --git a/tests/lib/Files/SimpleFS/SimpleFolderTest.php b/tests/lib/Files/SimpleFS/SimpleFolderTest.php index 4cab1136d82..50714b8356e 100644 --- a/tests/lib/Files/SimpleFS/SimpleFolderTest.php +++ b/tests/lib/Files/SimpleFS/SimpleFolderTest.php @@ -109,5 +109,4 @@ class SimpleFolderTest extends \Test\TestCase { $this->assertInstanceOf(ISimpleFile::class, $result[0]); $this->assertInstanceOf(ISimpleFile::class, $result[1]); } - } diff --git a/tests/lib/Files/Storage/CopyDirectoryTest.php b/tests/lib/Files/Storage/CopyDirectoryTest.php index d56cc37124d..25bdb016ead 100644 --- a/tests/lib/Files/Storage/CopyDirectoryTest.php +++ b/tests/lib/Files/Storage/CopyDirectoryTest.php @@ -44,7 +44,6 @@ class CopyDirectoryStorage extends StorageNoRecursiveCopy { * @package Test\Files\Storage */ class CopyDirectoryTest extends Storage { - protected function setUp(): void { parent::setUp(); $this->instance = new CopyDirectoryStorage([]); diff --git a/tests/lib/Files/Storage/HomeStorageQuotaTest.php b/tests/lib/Files/Storage/HomeStorageQuotaTest.php index 68fa4bb0bbb..cfee638d5f3 100644 --- a/tests/lib/Files/Storage/HomeStorageQuotaTest.php +++ b/tests/lib/Files/Storage/HomeStorageQuotaTest.php @@ -45,7 +45,9 @@ class HomeStorageQuotaTest extends \Test\TestCase { // clean up \OC_User::setUserId(''); $user = \OC::$server->getUserManager()->get($user1); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } \OC::$server->getConfig()->deleteAllUserValues($user1); \OC_Util::tearDownFS(); } @@ -73,9 +75,10 @@ class HomeStorageQuotaTest extends \Test\TestCase { // clean up \OC_User::setUserId(''); $user = \OC::$server->getUserManager()->get($user1); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } \OC::$server->getConfig()->deleteAllUserValues($user1); \OC_Util::tearDownFS(); } - } diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php index 9060ca2dac3..1f199239a8e 100644 --- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php @@ -9,7 +9,6 @@ namespace Test\Files\Storage\Wrapper; class EncodingTest extends \Test\Files\Storage\Storage { - const NFD_NAME = 'ümlaut'; const NFC_NAME = 'ümlaut'; diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index c50015483fb..73de60e3652 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -110,7 +110,6 @@ class EncryptionTest extends Storage { private $dummySize = -1; protected function setUp(): void { - parent::setUp(); $mockModule = $this->buildMockModule(); @@ -174,7 +173,9 @@ class EncryptionTest extends Storage { ->disableOriginalConstructor()->getMock(); $this->cache->expects($this->any()) ->method('get') - ->willReturnCallback(function ($path) {return ['encrypted' => false, 'path' => $path];}); + ->willReturnCallback(function ($path) { + return ['encrypted' => false, 'path' => $path]; + }); $this->mountManager = $this->createMock(\OC\Files\Mount\Manager::class); $this->mountManager->method('findByStorageId') @@ -244,7 +245,6 @@ class EncryptionTest extends Storage { * @param array $expected */ public function testGetMetaData($path, $metaData, $encrypted, $unencryptedSizeSet, $storedUnencryptedSize, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -273,7 +273,7 @@ class EncryptionTest extends Storage { ->setMethods(['getCache', 'verifyUnencryptedSize']) ->getMock(); - if($unencryptedSizeSet) { + if ($unencryptedSizeSet) { $this->invokePrivate($this->instance, 'unencryptedSize', [[$path => $storedUnencryptedSize]]); } @@ -298,10 +298,10 @@ class EncryptionTest extends Storage { } $result = $this->instance->getMetaData($path); - if(isset($expected['encrypted'])) { + if (isset($expected['encrypted'])) { $this->assertSame($expected['encrypted'], (bool)$result['encrypted']); - if(isset($expected['encryptedVersion'])) { + if (isset($expected['encryptedVersion'])) { $this->assertSame($expected['encryptedVersion'], $result['encryptedVersion']); } } @@ -352,7 +352,6 @@ class EncryptionTest extends Storage { $this->assertSame(42, $this->instance->filesize('/test.txt') ); - } /** @@ -561,7 +560,6 @@ class EncryptionTest extends Storage { * @param string $strippedPath */ public function testGetHeader($path, $strippedPathExists, $strippedPath) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -629,7 +627,6 @@ class EncryptionTest extends Storage { * @dataProvider dataTestGetHeaderAddLegacyModule */ public function testGetHeaderAddLegacyModule($header, $isEncrypted, $exists, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -645,7 +642,9 @@ class EncryptionTest extends Storage { ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('get') - ->willReturnCallback(function ($path) use ($isEncrypted) {return ['encrypted' => $isEncrypted, 'path' => $path];}); + ->willReturnCallback(function ($path) use ($isEncrypted) { + return ['encrypted' => $isEncrypted, 'path' => $path]; + }); $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') ->setConstructorArgs( @@ -792,7 +791,7 @@ class EncryptionTest extends Storage { }); $storage2->method('getId') ->willReturn('stroage2'); - if($expectedEncrypted) { + if ($expectedEncrypted) { $cache = $this->createMock(ICache::class); $cache->expects($this->once()) ->method('get') @@ -816,7 +815,7 @@ class EncryptionTest extends Storage { $expectedCachePut = [ 'encrypted' => $expectedEncrypted, ]; - if($expectedEncrypted === true) { + if ($expectedEncrypted === true) { $expectedCachePut['encryptedVersion'] = 1; } @@ -840,7 +839,6 @@ class EncryptionTest extends Storage { * @param bool $encrypted */ public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) { - $sourceStorage = $this->createMock(\OC\Files\Storage\Storage::class); $targetStorage = $this->createMock(\OC\Files\Storage\Storage::class); @@ -1043,5 +1041,4 @@ class EncryptionTest extends Storage { [true, null, false, true], ]; } - } diff --git a/tests/lib/Files/Stream/DummyEncryptionWrapper.php b/tests/lib/Files/Stream/DummyEncryptionWrapper.php index 599abf894ef..e66fae3d15d 100644 --- a/tests/lib/Files/Stream/DummyEncryptionWrapper.php +++ b/tests/lib/Files/Stream/DummyEncryptionWrapper.php @@ -32,5 +32,4 @@ class DummyEncryptionWrapper extends \OC\Files\Stream\Encryption { protected function parentStreamSeek($position) { return false; } - } diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index f884aefb7d8..e1ad3ec68fa 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -216,7 +216,7 @@ class EncryptionTest extends \Test\TestCase { fclose($stream); unlink($fileName); -} + } public function testSeek() { $fileName = tempnam("/tmp", "FOO"); @@ -252,7 +252,6 @@ class EncryptionTest extends \Test\TestCase { * @dataProvider dataFilesProvider */ public function testWriteReadBigFile($testFile) { - $expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/' . $testFile); // write it $fileName = tempnam("/tmp", "FOO"); @@ -290,7 +289,6 @@ class EncryptionTest extends \Test\TestCase { * @dataProvider dataFilesProvider */ public function testWriteToNonSeekableStorage($testFile) { - $wrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption') ->setMethods(['parentSeekStream'])->getMock(); $wrapper->expects($this->any())->method('parentSeekStream')->willReturn(false); @@ -324,7 +322,6 @@ class EncryptionTest extends \Test\TestCase { $this->assertEquals($expectedData, $data); unlink($fileName); - } /** diff --git a/tests/lib/Files/Type/LoaderTest.php b/tests/lib/Files/Type/LoaderTest.php index a99c80dac47..ccd37cbb655 100644 --- a/tests/lib/Files/Type/LoaderTest.php +++ b/tests/lib/Files/Type/LoaderTest.php @@ -89,5 +89,4 @@ class LoaderTest extends \Test\TestCase { $this->assertEquals($mimetypeId, $mimetypeId2); } - } diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php index c5183ac3929..376e72e6811 100644 --- a/tests/lib/Files/Utils/ScannerTest.php +++ b/tests/lib/Files/Utils/ScannerTest.php @@ -241,5 +241,4 @@ class ScannerTest extends \Test\TestCase { $this->assertTrue($cache->inCache('folder/bar.txt')); $this->assertFalse($cache->inCache('folder/subfolder/foobar.txt')); } - } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 369c94c3530..9dbe2a4e10e 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -804,7 +804,6 @@ class ViewTest extends \Test\TestCase { } public function xtestLongPath() { - $storage = new Temporary([]); Filesystem::mount($storage, [], '/'); @@ -1210,7 +1209,6 @@ class ViewTest extends \Test\TestCase { // second file not moved/copied $this->assertFalse($storage2->file_exists('dirtomove/indir2.txt')); $this->assertFalse($storage2->getCache()->get('dirtomove/indir2.txt')); - } public function testDeleteFailKeepCache() { @@ -1541,7 +1539,6 @@ class ViewTest extends \Test\TestCase { $this->assertFalse($this->isFileLocked($view, '/test//sub', ILockingProvider::LOCK_SHARED)); $this->assertFalse($this->isFileLocked($view, '/test//sub', ILockingProvider::LOCK_EXCLUSIVE)); - } public function hookPathProvider() { |