diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 15:19:56 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 15:19:56 +0300 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /apps/workflowengine/tests | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) |
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 'apps/workflowengine/tests')
-rw-r--r-- | apps/workflowengine/tests/Check/AbstractStringCheckTest.php | 5 | ||||
-rw-r--r-- | apps/workflowengine/tests/ManagerTest.php | 23 |
2 files changed, 14 insertions, 14 deletions
diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php index f9fc57a5331..083876268f1 100644 --- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php +++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php @@ -24,7 +24,6 @@ namespace OCA\WorkflowEngine\Tests\Check; use OCP\IL10N; class AbstractStringCheckTest extends \Test\TestCase { - protected function getCheckMock() { $l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() @@ -32,8 +31,8 @@ class AbstractStringCheckTest extends \Test\TestCase { $l->expects($this->any()) ->method('t') ->willReturnCallback(function ($string, $args) { - return sprintf($string, $args); - }); + return sprintf($string, $args); + }); $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck') ->setConstructorArgs([ diff --git a/apps/workflowengine/tests/ManagerTest.php b/apps/workflowengine/tests/ManagerTest.php index 191e7bfec84..512d5dc1f61 100644 --- a/apps/workflowengine/tests/ManagerTest.php +++ b/apps/workflowengine/tests/ManagerTest.php @@ -126,7 +126,7 @@ class ManagerTest extends TestCase { public function clearTables() { $query = $this->db->getQueryBuilder(); - foreach(['flow_checks', 'flow_operations', 'flow_operations_scope'] as $table) { + foreach (['flow_checks', 'flow_operations', 'flow_operations_scope'] as $table) { $query->delete($table) ->execute(); } @@ -274,7 +274,6 @@ class ManagerTest extends TestCase { array_walk($userOps, function ($op) { $this->assertTrue($op['class'] === 'OCA\WFE\TestOp'); }); - } public function testUpdateOperation() { @@ -285,9 +284,9 @@ class ManagerTest extends TestCase { $this->container->expects($this->any()) ->method('query') ->willReturnCallback(function ($class) { - if(substr($class, -2) === 'Op') { + if (substr($class, -2) === 'Op') { return $this->createMock(IOperation::class); - } elseif($class === File::class) { + } elseif ($class === File::class) { return $this->getMockBuilder(File::class) ->setConstructorArgs([ $this->l, @@ -331,7 +330,7 @@ class ManagerTest extends TestCase { $this->assertSame('Test02a', $op['name']); $this->assertSame('barfoo', $op['operation']); - foreach([[$adminScope, $opId2], [$userScope, $opId1]] as $run) { + foreach ([[$adminScope, $opId2], [$userScope, $opId1]] as $run) { try { /** @noinspection PhpUnhandledExceptionInspection */ $this->manager->updateOperation($run[1], 'Evil', [$check2], 'hackx0r', $run[0], $entity, []); @@ -361,7 +360,7 @@ class ManagerTest extends TestCase { ); $this->invokePrivate($this->manager, 'addScope', [$opId2, $userScope]); - foreach([[$adminScope, $opId2], [$userScope, $opId1]] as $run) { + foreach ([[$adminScope, $opId2], [$userScope, $opId1]] as $run) { try { /** @noinspection PhpUnhandledExceptionInspection */ $this->manager->deleteOperation($run[1], $run[0]); @@ -376,11 +375,11 @@ class ManagerTest extends TestCase { /** @noinspection PhpUnhandledExceptionInspection */ $this->manager->deleteOperation($opId2, $userScope); - foreach([$opId1, $opId2] as $opId) { + foreach ([$opId1, $opId2] as $opId) { try { $this->invokePrivate($this->manager, 'getOperation', [$opId]); $this->assertTrue(false, 'UnexpectedValueException not thrown'); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->assertInstanceOf(\UnexpectedValueException::class, $e); } } @@ -423,13 +422,15 @@ class ManagerTest extends TestCase { $this->assertCount(2, $entities); $entityTypeCounts = array_reduce($entities, function (array $carry, IEntity $entity) { - if($entity instanceof File) $carry[0]++; - elseif($entity instanceof IEntity) $carry[1]++; + if ($entity instanceof File) { + $carry[0]++; + } elseif ($entity instanceof IEntity) { + $carry[1]++; + } return $carry; }, [0, 0]); $this->assertSame(1, $entityTypeCounts[0]); $this->assertSame(1, $entityTypeCounts[1]); } - } |