From caff1023ea72bb2ea94130e18a2a6e2ccf819e5f Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 10 Apr 2020 14:19:56 +0200 Subject: 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 --- .../tests/Controller/AppConfigControllerTest.php | 5 ----- .../provisioning_api/tests/Controller/AppsControllerTest.php | 2 +- .../tests/Controller/GroupsControllerTest.php | 2 -- .../tests/Controller/UsersControllerTest.php | 12 ++++++------ .../tests/Middleware/ProvisioningApiMiddlewareTest.php | 1 - apps/provisioning_api/tests/TestCase.php | 2 +- 6 files changed, 8 insertions(+), 16 deletions(-) (limited to 'apps/provisioning_api/tests') diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php index a87f69a25b3..50a00a1e93f 100644 --- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php @@ -49,7 +49,6 @@ class AppConfigControllerTest extends TestCase { $this->config = $this->createMock(IConfig::class); $this->appConfig = $this->createMock(IAppConfig::class); - } /** @@ -105,7 +104,6 @@ class AppConfigControllerTest extends TestCase { * @param int $status */ public function testGetKeys($app, $keys, $throws, $status) { - $api = $this->getInstance(['verifyAppId']); if ($throws instanceof \Exception) { $api->expects($this->once()) @@ -153,7 +151,6 @@ class AppConfigControllerTest extends TestCase { * @param int $status */ public function testGetValue($app, $key, $default, $return, $throws, $status) { - $api = $this->getInstance(['verifyAppId']); if ($throws instanceof \Exception) { $api->expects($this->once()) @@ -202,7 +199,6 @@ class AppConfigControllerTest extends TestCase { * @param int $status */ public function testSetValue($app, $key, $value, $appThrows, $keyThrows, $status) { - $api = $this->getInstance(['verifyAppId', 'verifyConfigKey']); if ($appThrows instanceof \Exception) { $api->expects($this->once()) @@ -267,7 +263,6 @@ class AppConfigControllerTest extends TestCase { * @param int $status */ public function testDeleteValue($app, $key, $appThrows, $keyThrows, $status) { - $api = $this->getInstance(['verifyAppId', 'verifyConfigKey']); if ($appThrows instanceof \Exception) { $api->expects($this->once()) diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php index bfc7a2f623a..28867f0b80b 100644 --- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php @@ -102,7 +102,7 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { $data = $result->getData(); $apps = (new \OC_App)->listAllApps(); $list = []; - foreach($apps as $app) { + foreach ($apps as $app) { $list[] = $app['id']; } $disabled = array_diff($list, \OC_App::getEnabledApps()); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 70a920b743e..0ed6d58e217 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -219,7 +219,6 @@ class GroupsControllerTest extends \Test\TestCase { $result = $this->api->getGroups($search, $limit, $offset); $this->assertEquals(['groups' => ['group1', 'group2']], $result->getData()); - } /** @@ -260,7 +259,6 @@ class GroupsControllerTest extends \Test\TestCase { ] ]], $result->getData()); - } public function testGetGroupAsSubadmin() { diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index aff12547ec0..48b970e9687 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -440,7 +440,7 @@ class UsersControllerTest extends TestCase { ->expects($this->any()) ->method('getAppValue') ->willReturnCallback(function ($appid, $key, $default) { - if($key === 'newUser.generateUserID') { + if ($key === 'newUser.generateUserID') { return 'yes'; } return null; @@ -477,7 +477,9 @@ class UsersControllerTest extends TestCase { $this->secureRandom->expects($this->any()) ->method('generate') ->with(10) - ->willReturnCallback(function () { return (string)rand(1000000000, 9999999999); }); + ->willReturnCallback(function () { + return (string)rand(1000000000, 9999999999); + }); $this->assertTrue(key_exists( 'id', @@ -495,7 +497,7 @@ class UsersControllerTest extends TestCase { ->expects($this->any()) ->method('getAppValue') ->willReturnCallback(function ($appid, $key, $default) { - if($key === 'newUser.generateUserID') { + if ($key === 'newUser.generateUserID') { return 'yes'; } return null; @@ -538,7 +540,7 @@ class UsersControllerTest extends TestCase { ->expects($this->any()) ->method('getAppValue') ->willReturnCallback(function ($appid, $key, $default) { - if($key === 'newUser.requireEmail') { + if ($key === 'newUser.requireEmail') { return 'yes'; } return null; @@ -1590,7 +1592,6 @@ class UsersControllerTest extends TestCase { } public function testEditUserSelfEditChangeLanguage() { - $this->l10nFactory->expects($this->once()) ->method('findAvailableLanguages') ->willReturn(['en', 'de', 'sv']); @@ -1683,7 +1684,6 @@ class UsersControllerTest extends TestCase { } public function testEditUserAdminEditChangeLanguage() { - $this->l10nFactory->expects($this->once()) ->method('findAvailableLanguages') ->willReturn(['en', 'de', 'sv']); diff --git a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php index 368fa40356f..b3b2184b2ba 100644 --- a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php +++ b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php @@ -118,6 +118,5 @@ class ProvisioningApiMiddlewareTest extends TestCase { $this->assertTrue($forwared); $this->assertSame($exception, $e); } - } } diff --git a/apps/provisioning_api/tests/TestCase.php b/apps/provisioning_api/tests/TestCase.php index f2495cdba62..7ddebfcf322 100644 --- a/apps/provisioning_api/tests/TestCase.php +++ b/apps/provisioning_api/tests/TestCase.php @@ -65,7 +65,7 @@ abstract class TestCase extends \Test\TestCase { } protected function tearDown(): void { - foreach($this->users as $user) { + foreach ($this->users as $user) { $user->delete(); } -- cgit v1.2.3