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/Core | |
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/Core')
24 files changed, 13 insertions, 50 deletions
diff --git a/tests/Core/Command/Config/System/SetConfigTest.php b/tests/Core/Command/Config/System/SetConfigTest.php index e359e846aa7..0a446c5fd1e 100644 --- a/tests/Core/Command/Config/System/SetConfigTest.php +++ b/tests/Core/Command/Config/System/SetConfigTest.php @@ -175,5 +175,4 @@ class SetConfigTest extends TestCase { $this->invokePrivate($this->command, 'castValue', [$value, $type]); } - } diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index 4f3fc432dfe..1d33dc570b6 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -85,14 +85,12 @@ class ChangeKeyStorageRootTest extends TestCase { $this->util, $this->questionHelper ); - } /** * @dataProvider dataTestExecute */ public function testExecute($newRoot, $answer, $successMoveKey) { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') ->setConstructorArgs( [ @@ -164,7 +162,6 @@ class ChangeKeyStorageRootTest extends TestCase { $changeKeyStorageRoot->expects($this->at(2))->method('moveUserKeys')->with('oldRoot', 'newRoot', $this->outputInterface); $this->invokePrivate($changeKeyStorageRoot, 'moveAllKeys', ['oldRoot', 'newRoot', $this->outputInterface]); - } public function testPrepareNewRoot() { @@ -210,7 +207,6 @@ class ChangeKeyStorageRootTest extends TestCase { * @param bool $executeRename */ public function testMoveSystemKeys($dirExists, $targetExists, $executeRename) { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') ->setConstructorArgs( [ @@ -235,7 +231,6 @@ class ChangeKeyStorageRootTest extends TestCase { } $this->invokePrivate($changeKeyStorageRoot, 'moveSystemKeys', ['oldRoot', 'newRoot']); - } public function dataTestMoveSystemKeys() { @@ -249,7 +244,6 @@ class ChangeKeyStorageRootTest extends TestCase { public function testMoveUserKeys() { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') ->setConstructorArgs( [ @@ -280,7 +274,6 @@ class ChangeKeyStorageRootTest extends TestCase { * @param bool $shouldRename */ public function testMoveUserEncryptionFolder($userExists, $isDir, $targetExists, $shouldRename) { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') ->setConstructorArgs( [ @@ -310,7 +303,6 @@ class ChangeKeyStorageRootTest extends TestCase { } $this->invokePrivate($changeKeyStorageRoot, 'moveUserEncryptionFolder', ['user1', 'oldRoot', 'newRoot']); - } public function dataTestMoveUserEncryptionFolder() { @@ -379,5 +371,4 @@ class ChangeKeyStorageRootTest extends TestCase { $this->invokePrivate($this->changeKeyStorageRoot, 'targetExists', ['path']); } - } diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php index a6918404d71..33140fa2644 100644 --- a/tests/Core/Command/Encryption/DecryptAllTest.php +++ b/tests/Core/Command/Encryption/DecryptAllTest.php @@ -83,7 +83,6 @@ class DecryptAllTest extends TestCase { $this->appManager->expects($this->any()) ->method('isEnabledForUser') ->with('files_trashbin')->willReturn(true); - } public function testMaintenanceAndTrashbin() { @@ -127,7 +126,6 @@ class DecryptAllTest extends TestCase { * @dataProvider dataTestExecute */ public function testExecute($encryptionEnabled, $continue) { - $instance = new DecryptAll( $this->encryptionManager, $this->appManager, @@ -217,9 +215,10 @@ class DecryptAllTest extends TestCase { $this->decryptAll->expects($this->once()) ->method('decryptAll') ->with($this->consoleInput, $this->consoleOutput, 'user1') - ->willReturnCallback(function () { throw new \Exception(); }); + ->willReturnCallback(function () { + throw new \Exception(); + }); $this->invokePrivate($instance, 'execute', [$this->consoleInput, $this->consoleOutput]); } - } diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php index 4a0d40ea5b3..add57c0d9e5 100644 --- a/tests/Core/Command/Encryption/EncryptAllTest.php +++ b/tests/Core/Command/Encryption/EncryptAllTest.php @@ -80,7 +80,6 @@ class EncryptAllTest extends TestCase { ->method('isInteractive') ->willReturn(true); $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); - } public function testEncryptAll() { @@ -102,7 +101,6 @@ class EncryptAllTest extends TestCase { * @dataProvider dataTestExecute */ public function testExecute($answer, $askResult) { - $command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper); $this->encryptionManager->expects($this->once())->method('isEnabled')->willReturn(true); @@ -137,5 +135,4 @@ class EncryptAllTest extends TestCase { $this->encryptionModule->expects($this->never())->method('encryptAll'); $this->invokePrivate($command, 'execute', [$this->consoleInput, $this->consoleOutput]); } - } diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php index 87cf3c6b8d1..35449a9e3f4 100644 --- a/tests/Core/Command/Group/AddTest.php +++ b/tests/Core/Command/Group/AddTest.php @@ -94,6 +94,4 @@ class AddTest extends TestCase { $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]); } - - } diff --git a/tests/Core/Command/Group/AddUserTest.php b/tests/Core/Command/Group/AddUserTest.php index ad7267ca841..3f7f811b7e8 100644 --- a/tests/Core/Command/Group/AddUserTest.php +++ b/tests/Core/Command/Group/AddUserTest.php @@ -115,6 +115,4 @@ class AddUserTest extends TestCase { $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]); } - - } diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php index 19ed9942145..4c539728949 100644 --- a/tests/Core/Command/Group/ListCommandTest.php +++ b/tests/Core/Command/Group/ListCommandTest.php @@ -123,6 +123,4 @@ class ListCommandTest extends TestCase { $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]); } - - } diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php index f9a25face3b..906247d0896 100644 --- a/tests/Core/Command/Group/RemoveUserTest.php +++ b/tests/Core/Command/Group/RemoveUserTest.php @@ -115,6 +115,4 @@ class RemoveUserTest extends TestCase { $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]); } - - } diff --git a/tests/Core/Command/Log/FileTest.php b/tests/Core/Command/Log/FileTest.php index 58507227780..4ecbf8914b6 100644 --- a/tests/Core/Command/Log/FileTest.php +++ b/tests/Core/Command/Log/FileTest.php @@ -119,5 +119,4 @@ class FileTest extends TestCase { self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } - } diff --git a/tests/Core/Command/Log/ManageTest.php b/tests/Core/Command/Log/ManageTest.php index 4425a9e0054..2724bba64dd 100644 --- a/tests/Core/Command/Log/ManageTest.php +++ b/tests/Core/Command/Log/ManageTest.php @@ -181,5 +181,4 @@ class ManageTest extends TestCase { self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } - } diff --git a/tests/Core/Command/TwoFactorAuth/CleanupTest.php b/tests/Core/Command/TwoFactorAuth/CleanupTest.php index 24aaa9abce2..98425aee223 100644 --- a/tests/Core/Command/TwoFactorAuth/CleanupTest.php +++ b/tests/Core/Command/TwoFactorAuth/CleanupTest.php @@ -62,5 +62,4 @@ class CleanupTest extends TestCase { $output = $this->cmd->getDisplay(); $this->assertContains("All user-provider associations for provider u2f have been removed", $output); } - } diff --git a/tests/Core/Command/TwoFactorAuth/EnableTest.php b/tests/Core/Command/TwoFactorAuth/EnableTest.php index faf00ed1ded..f3b66912f43 100644 --- a/tests/Core/Command/TwoFactorAuth/EnableTest.php +++ b/tests/Core/Command/TwoFactorAuth/EnableTest.php @@ -109,5 +109,4 @@ class EnableTest extends TestCase { $this->assertEquals(0, $rc); $this->assertContains("Two-factor provider totp enabled for user belle", $this->command->getDisplay()); } - } diff --git a/tests/Core/Command/TwoFactorAuth/EnforceTest.php b/tests/Core/Command/TwoFactorAuth/EnforceTest.php index aa2cbc10620..48c09f7e639 100644 --- a/tests/Core/Command/TwoFactorAuth/EnforceTest.php +++ b/tests/Core/Command/TwoFactorAuth/EnforceTest.php @@ -143,5 +143,4 @@ class EnforceTest extends TestCase { $display = $this->command->getDisplay(); $this->assertContains("Two-factor authentication is not enforced", $display); } - } diff --git a/tests/Core/Command/TwoFactorAuth/StateTest.php b/tests/Core/Command/TwoFactorAuth/StateTest.php index 8d1b28862d3..ce52bcf2751 100644 --- a/tests/Core/Command/TwoFactorAuth/StateTest.php +++ b/tests/Core/Command/TwoFactorAuth/StateTest.php @@ -109,5 +109,4 @@ class StateTest extends TestCase { $output = $this->cmd->getDisplay(); $this->assertContains("Two-factor authentication is enabled for user mohamed", $output); } - } diff --git a/tests/Core/Command/User/SettingTest.php b/tests/Core/Command/User/SettingTest.php index 4aa3b5e4801..02a4dbfec09 100644 --- a/tests/Core/Command/User/SettingTest.php +++ b/tests/Core/Command/User/SettingTest.php @@ -75,7 +75,6 @@ class SettingTest extends TestCase { ->getMock(); return $mock; } - } public function dataCheckInput() { @@ -292,7 +291,6 @@ class SettingTest extends TestCase { $this->config->expects($this->once()) ->method('deleteUserValue') ->with('username', 'appname', 'configkey'); - } else { $this->consoleOutput->expects($this->once()) ->method('writeln') diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index d2ae9b036b9..38876f02681 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -564,5 +564,4 @@ class AvatarControllerTest extends \Test\TestCase { $this->assertEquals('File is too big', $response->getData()['data']['message']); } - } diff --git a/tests/Core/Controller/CSRFTokenControllerTest.php b/tests/Core/Controller/CSRFTokenControllerTest.php index 88e54ee864a..557a6c5f6f0 100644 --- a/tests/Core/Controller/CSRFTokenControllerTest.php +++ b/tests/Core/Controller/CSRFTokenControllerTest.php @@ -78,5 +78,4 @@ class CSRFTokenControllerTest extends TestCase { $this->assertInstanceOf(JSONResponse::class, $response); $this->assertSame(Http::STATUS_FORBIDDEN, $response->getStatus()); } - } diff --git a/tests/Core/Controller/CssControllerTest.php b/tests/Core/Controller/CssControllerTest.php index d1d3ae7eb47..93151065b3c 100644 --- a/tests/Core/Controller/CssControllerTest.php +++ b/tests/Core/Controller/CssControllerTest.php @@ -182,5 +182,4 @@ class CssControllerTest extends TestCase { $result = $this->controller->getCss('file.css', 'myapp'); $this->assertEquals($expected, $result); } - } diff --git a/tests/Core/Controller/JsControllerTest.php b/tests/Core/Controller/JsControllerTest.php index 0b2c6a28f5b..99f58d7e9d8 100644 --- a/tests/Core/Controller/JsControllerTest.php +++ b/tests/Core/Controller/JsControllerTest.php @@ -182,5 +182,4 @@ class JsControllerTest extends TestCase { $result = $this->controller->getJs('file.js', 'myapp'); $this->assertEquals($expected, $result); } - } diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index ffd8a5a8c02..09f224131f5 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -766,7 +766,9 @@ class LostControllerTest extends \Test\TestCase { $encryptionModule = $this->createMock(IEncryptionModule::class); $encryptionModule->expects($this->once())->method('needDetailedAccessList')->willReturn(true); $this->encryptionManager->expects($this->once())->method('getEncryptionModules') - ->willReturn([0 => ['callback' => function () use ($encryptionModule) { return $encryptionModule; }]]); + ->willReturn([0 => ['callback' => function () use ($encryptionModule) { + return $encryptionModule; + }]]); $response = $this->lostController->setPassword('myToken', 'user', 'newpass', false); $expectedResponse = ['status' => 'error', 'msg' => '', 'encryption' => true]; $this->assertSame($expectedResponse, $response); @@ -776,7 +778,9 @@ class LostControllerTest extends \Test\TestCase { $encryptionModule = $this->createMock(IEncryptionModule::class); $encryptionModule->expects($this->once())->method('needDetailedAccessList')->willReturn(false); $this->encryptionManager->expects($this->once())->method('getEncryptionModules') - ->willReturn([0 => ['callback' => function () use ($encryptionModule) { return $encryptionModule; }]]); + ->willReturn([0 => ['callback' => function () use ($encryptionModule) { + return $encryptionModule; + }]]); $this->config->method('getUserValue') ->with('ValidTokenUser', 'core', 'lostpassword', null) ->willReturn('encryptedData'); diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php index 4a4ad4b49e3..254013a7350 100644 --- a/tests/Core/Controller/NavigationControllerTest.php +++ b/tests/Core/Controller/NavigationControllerTest.php @@ -87,14 +87,11 @@ class NavigationControllerTest extends TestCase { $this->assertInstanceOf(DataResponse::class, $actual); $this->assertEquals('http://localhost/index.php/apps/files', $actual->getData()[0]['href']); $this->assertEquals('http://localhost/icon', $actual->getData()[0]['icon']); - - } else { $actual = $this->controller->getAppsNavigation($absolute); $this->assertInstanceOf(DataResponse::class, $actual); $this->assertEquals('/index.php/apps/files', $actual->getData()[0]['href']); $this->assertEquals('icon', $actual->getData()[0]['icon']); - } } @@ -138,9 +135,9 @@ class NavigationControllerTest extends TestCase { ->method('getAll') ->with('link') ->willReturn($navigation); - $actual = $this->controller->getAppsNavigation(); - $this->assertInstanceOf(DataResponse::class, $actual); - $this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus()); + $actual = $this->controller->getAppsNavigation(); + $this->assertInstanceOf(DataResponse::class, $actual); + $this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus()); } public function testGetSettingsNavigationEtagMatch() { @@ -157,5 +154,4 @@ class NavigationControllerTest extends TestCase { $this->assertInstanceOf(DataResponse::class, $actual); $this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus()); } - } diff --git a/tests/Core/Controller/SvgControllerTest.php b/tests/Core/Controller/SvgControllerTest.php index 4413fbb9ae5..684199f5cb6 100644 --- a/tests/Core/Controller/SvgControllerTest.php +++ b/tests/Core/Controller/SvgControllerTest.php @@ -1,6 +1,6 @@ <?php -declare (strict_types = 1); +declare(strict_types = 1); /** * @copyright Copyright (c) 2018 Michael Weimann <mail@michael-weimann.eu> * @@ -37,7 +37,6 @@ use Test\TestCase; * This class provides test cases for the svg controller */ class SvgControllerTest extends TestCase { - const TEST_IMAGES_SOURCE_PATH = __DIR__ . '/../../data/svg'; const TEST_IMAGES_PATH = __DIR__ . '/../../../core/img/testImages'; const TEST_IMAGE_MIXED = 'mixed-source.svg'; diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php index fa155500567..a7907343c24 100644 --- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php +++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php @@ -443,5 +443,4 @@ class TwoFactorChallengeControllerTest extends TestCase { $this->assertEquals($expected, $response); } - } diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php index ac3a5fbc017..5ef2b75fde6 100644 --- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php +++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php @@ -320,5 +320,4 @@ class TwoFactorMiddlewareTest extends TestCase { ->getMock(); $this->middleware->beforeController($twoFactorChallengeController, 'index'); } - } |