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/AppFramework/Db | |
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/AppFramework/Db')
-rw-r--r-- | tests/lib/AppFramework/Db/EntityTest.php | 1 | ||||
-rw-r--r-- | tests/lib/AppFramework/Db/MapperTest.php | 24 | ||||
-rw-r--r-- | tests/lib/AppFramework/Db/MapperTestUtility.php | 20 | ||||
-rw-r--r-- | tests/lib/AppFramework/Db/QBMapperTest.php | 2 |
4 files changed, 26 insertions, 21 deletions
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php index faff2649bc6..73138749a33 100644 --- a/tests/lib/AppFramework/Db/EntityTest.php +++ b/tests/lib/AppFramework/Db/EntityTest.php @@ -62,7 +62,6 @@ class TestEntity extends Entity { class EntityTest extends \Test\TestCase { - private $entity; protected function setUp(): void { diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php index 4509b1b80c7..e5a4b63b7a3 100644 --- a/tests/lib/AppFramework/Db/MapperTest.php +++ b/tests/lib/AppFramework/Db/MapperTest.php @@ -44,12 +44,24 @@ class Example extends Entity { class ExampleMapper extends Mapper { - public function __construct(IDBConnection $db) { parent::__construct($db, 'table'); } - public function find($table, $id) { return $this->findOneQuery($table, $id); } - public function findOneEntity($table, $id) { return $this->findEntity($table, $id); } - public function findAllEntities($table) { return $this->findEntities($table); } - public function mapRow($row) { return $this->mapRowToEntity($row); } - public function execSql($sql, $params) { return $this->execute($sql, $params); } + public function __construct(IDBConnection $db) { + parent::__construct($db, 'table'); + } + public function find($table, $id) { + return $this->findOneQuery($table, $id); + } + public function findOneEntity($table, $id) { + return $this->findEntity($table, $id); + } + public function findAllEntities($table) { + return $this->findEntities($table); + } + public function mapRow($row) { + return $this->mapRowToEntity($row); + } + public function execSql($sql, $params) { + return $this->execute($sql, $params); + } } diff --git a/tests/lib/AppFramework/Db/MapperTestUtility.php b/tests/lib/AppFramework/Db/MapperTestUtility.php index 9ee83e5a161..1224e6d24ed 100644 --- a/tests/lib/AppFramework/Db/MapperTestUtility.php +++ b/tests/lib/AppFramework/Db/MapperTestUtility.php @@ -90,24 +90,24 @@ abstract class MapperTestUtility extends \Test\TestCase { */ protected function setMapperResult($sql, $arguments=[], $returnRows=[], $limit=null, $offset=null, $expectClose=false) { - if($limit === null && $offset === null) { + if ($limit === null && $offset === null) { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql)) ->will(($this->returnValue($this->query))); - } elseif($limit !== null && $offset === null) { + } elseif ($limit !== null && $offset === null) { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql), $this->equalTo($limit)) ->will(($this->returnValue($this->query))); - } elseif($limit === null && $offset !== null) { + } elseif ($limit === null && $offset !== null) { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql), $this->equalTo(null), $this->equalTo($offset)) ->will(($this->returnValue($this->query))); - } else { + } else { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql), @@ -128,7 +128,7 @@ abstract class MapperTestUtility extends \Test\TestCase { $iterator = $iterators[$fetchAt]; $result = $iterator->next(); - if($result === false) { + if ($result === false) { $fetchAt++; } @@ -139,7 +139,7 @@ abstract class MapperTestUtility extends \Test\TestCase { ); if ($this->isAssocArray($arguments)) { - foreach($arguments as $key => $argument) { + foreach ($arguments as $key => $argument) { $pdoConstant = $this->getPDOType($argument); $this->query->expects($this->at($this->queryAt)) ->method('bindValue') @@ -150,7 +150,7 @@ abstract class MapperTestUtility extends \Test\TestCase { } } else { $index = 1; - foreach($arguments as $argument) { + foreach ($arguments as $argument) { $pdoConstant = $this->getPDOType($argument); $this->query->expects($this->at($this->queryAt)) ->method('bindValue') @@ -165,7 +165,6 @@ abstract class MapperTestUtility extends \Test\TestCase { $this->query->expects($this->at($this->queryAt)) ->method('execute') ->willReturnCallback(function ($sql, $p=null, $o=null, $s=null) { - }); $this->queryAt++; @@ -182,13 +181,10 @@ abstract class MapperTestUtility extends \Test\TestCase { $this->prepareAt++; $this->fetchAt++; } - - } class ArgumentIterator { - private $arguments; public function __construct($arguments) { @@ -197,7 +193,7 @@ class ArgumentIterator { public function next() { $result = array_shift($this->arguments); - if($result === null){ + if ($result === null) { return false; } else { return $result; diff --git a/tests/lib/AppFramework/Db/QBMapperTest.php b/tests/lib/AppFramework/Db/QBMapperTest.php index 6fa0fe10d88..7865979ef41 100644 --- a/tests/lib/AppFramework/Db/QBMapperTest.php +++ b/tests/lib/AppFramework/Db/QBMapperTest.php @@ -42,7 +42,6 @@ use OCP\IDBConnection; * @method void setIntegerProp(integer $integerProp) */ class QBTestEntity extends Entity { - protected $intProp; protected $boolProp; protected $stringProp; @@ -106,7 +105,6 @@ class QBMapperTest extends \Test\TestCase { * @throws \ReflectionException */ protected function setUp(): void { - $this->db = $this->getMockBuilder(IDBConnection::class) ->disableOriginalConstructor() ->getMock(); |