Fix php cs issues

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-04-22 19:57:19 +02:00
parent 7ad5daabeb
commit 52febb396c
130 changed files with 1068 additions and 1424 deletions

View File

@@ -30,9 +30,8 @@ use Test\AppFramework\Db\MapperTestUtility;
/**
* @group DB
*/
class AclMapperTest extends MapperTestUtility {
private $dbConnection;
class AclMapperTest extends MapperTestUtility {
private $dbConnection;
private $aclMapper;
private $boardMapper;
private $userManager;
@@ -46,33 +45,33 @@ class AclMapperTest extends MapperTestUtility {
parent::setUp();
$this->dbConnection = \OC::$server->getDatabaseConnection();
$this->aclMapper = new AclMapper($this->dbConnection);
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->boardMapper = new BoardMapper(
$this->dbConnection,
\OC::$server->query(LabelMapper::class),
$this->aclMapper,
\OC::$server->query(StackMapper::class),
$this->aclMapper = new AclMapper($this->dbConnection);
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->boardMapper = new BoardMapper(
$this->dbConnection,
\OC::$server->query(LabelMapper::class),
$this->aclMapper,
\OC::$server->query(StackMapper::class),
$this->userManager,
$this->groupManager
);
$this->boards = [
$this->boardMapper->insert($this->getBoard('MyBoard 1', 'user1')),
$this->boardMapper->insert($this->getBoard('MyBoard 2', 'user2')),
$this->boardMapper->insert($this->getBoard('MyBoard 3', 'user3'))
];
$this->boards = [
$this->boardMapper->insert($this->getBoard('MyBoard 1', 'user1')),
$this->boardMapper->insert($this->getBoard('MyBoard 2', 'user2')),
$this->boardMapper->insert($this->getBoard('MyBoard 3', 'user3'))
];
$this->acls = [
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[1]->getId())),
$this->aclMapper->insert($this->getAcl('user','user2', true, false, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user3', true, true, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[2]->getId()))
];
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[1]->getId())),
$this->aclMapper->insert($this->getAcl('user','user2', true, false, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user3', true, true, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[2]->getId()))
];
foreach ($this->acls as $acl) {
$acl->resetUpdatedFields();
}
foreach ($this->acls as $acl) {
$acl->resetUpdatedFields();
}
}
/** @return Acl */
public function getAcl($type='user', $participant='admin', $edit=false, $share=false, $manage=false, $boardId=123) {
@@ -88,39 +87,38 @@ class AclMapperTest extends MapperTestUtility {
/** @return Board */
public function getBoard($title, $owner) {
$board = new Board();
$board->setTitle($title);
$board->setOwner($owner);
return $board;
}
$board = new Board();
$board->setTitle($title);
$board->setOwner($owner);
return $board;
}
public function testFindAllDatabase() {
$actual = $this->aclMapper->findAll($this->boards[0]->getId());
$expected = [$this->acls[1], $this->acls[2]];
$this->assertEquals($expected, $actual);
}
public function testIsOwnerDatabase() {
$this->assertTrue($this->aclMapper->isOwner('user2', $this->acls[0]->getId()));
$this->assertTrue($this->aclMapper->isOwner('user1', $this->acls[1]->getId()));
$this->assertTrue($this->aclMapper->isOwner('user1', $this->acls[2]->getId()));
$this->assertTrue($this->aclMapper->isOwner('user3', $this->acls[3]->getId()));
$this->assertFalse($this->aclMapper->isOwner('user3', $this->acls[0]->getId()));
$this->assertFalse($this->aclMapper->isOwner('user1', $this->acls[0]->getId()));
}
$actual = $this->aclMapper->findAll($this->boards[0]->getId());
$expected = [$this->acls[1], $this->acls[2]];
$this->assertEquals($expected, $actual);
}
public function testIsOwnerDatabase() {
$this->assertTrue($this->aclMapper->isOwner('user2', $this->acls[0]->getId()));
$this->assertTrue($this->aclMapper->isOwner('user1', $this->acls[1]->getId()));
$this->assertTrue($this->aclMapper->isOwner('user1', $this->acls[2]->getId()));
$this->assertTrue($this->aclMapper->isOwner('user3', $this->acls[3]->getId()));
$this->assertFalse($this->aclMapper->isOwner('user3', $this->acls[0]->getId()));
$this->assertFalse($this->aclMapper->isOwner('user1', $this->acls[0]->getId()));
}
public function testFindBoardIdDatabase() {
$this->assertEquals($this->boards[0]->getId(), $this->aclMapper->findBoardId($this->acls[1]->getId()));
}
public function testFindBoardIdDatabase() {
$this->assertEquals($this->boards[0]->getId(), $this->aclMapper->findBoardId($this->acls[1]->getId()));
}
public function tearDown(): void {
parent::tearDown();
foreach ($this->acls as $acl) {
$this->aclMapper->delete($acl);
}
foreach ($this->boards as $board) {
$this->boardMapper->delete($board);
}
}
public function tearDown(): void {
parent::tearDown();
foreach ($this->acls as $acl) {
$this->aclMapper->delete($acl);
}
foreach ($this->boards as $board) {
$this->boardMapper->delete($board);
}
}
}

View File

@@ -5,26 +5,25 @@
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Db;
class AclTest extends \Test\TestCase {
private function createAclUser() {
$acl = new Acl();
$acl->setId(1);
@@ -103,7 +102,6 @@ class AclTest extends \Test\TestCase {
$this->assertEquals(false, $acl->getPermission(Acl::PERMISSION_EDIT));
$this->assertEquals(false, $acl->getPermission(Acl::PERMISSION_MANAGE));
$this->assertEquals(false, $acl->getPermission(Acl::PERMISSION_SHARE));
$this->assertEquals(false, $acl->getPermission(5));
$this->assertEquals(false, $acl->getPermission(5));
}
}
}

View File

@@ -25,17 +25,16 @@ namespace OCA\Deck\Db;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
use Test\AppFramework\Db\MapperTestUtility;
/**
* @group DB
*/
class AttachmentMapperTest extends MapperTestUtility {
class AttachmentMapperTest extends MapperTestUtility {
/** @var IDBConnection */
private $dbConnection;
private $dbConnection;
/** @var AttachmentMapper */
private $attachmentMapper;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
@@ -54,13 +53,13 @@ class AttachmentMapperTest extends MapperTestUtility {
$this->cardMapper = $this->createMock(CardMapper::class);
$this->dbConnection = \OC::$server->getDatabaseConnection();
$this->attachmentMapper = new AttachmentMapper(
$this->dbConnection,
$this->cardMapper,
$this->attachmentMapper = new AttachmentMapper(
$this->dbConnection,
$this->cardMapper,
$this->userManager
);
$this->attachments = [
$this->createAttachmentEntity(1, 'deck_file', 'file1.pdf'),
);
$this->attachments = [
$this->createAttachmentEntity(1, 'deck_file', 'file1.pdf'),
$this->createAttachmentEntity(1, 'deck_file', 'file2.pdf'),
$this->createAttachmentEntity(2, 'deck_file', 'file3.pdf'),
$this->createAttachmentEntity(3, 'deck_file', 'file4.pdf')
@@ -138,11 +137,10 @@ class AttachmentMapperTest extends MapperTestUtility {
}
}
public function tearDown(): void {
parent::tearDown();
foreach ($this->attachments as $attachment) {
$this->attachmentMapper->delete($attachment);
}
}
public function tearDown(): void {
parent::tearDown();
foreach ($this->attachments as $attachment) {
$this->attachmentMapper->delete($attachment);
}
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Db;
@@ -48,4 +48,4 @@ class AttachmentTest extends \Test\TestCase {
], $board->jsonSerialize());
}
}
}

View File

@@ -31,11 +31,11 @@ use Test\AppFramework\Db\MapperTestUtility;
/**
* @group DB
*/
class BoardMapperTest extends MapperTestUtility {
class BoardMapperTest extends MapperTestUtility {
/** @var IDBConnection */
private $dbConnection;
/** @var AclMapper|\PHPUnit\Framework\MockObject\MockObject */
private $dbConnection;
/** @var AclMapper|\PHPUnit\Framework\MockObject\MockObject */
private $aclMapper;
/** @var BoardMapper */
private $boardMapper;
@@ -55,35 +55,35 @@ class BoardMapperTest extends MapperTestUtility {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->dbConnection = \OC::$server->getDatabaseConnection();
$this->boardMapper = new BoardMapper(
$this->dbConnection,
\OC::$server->query(LabelMapper::class),
\OC::$server->query(AclMapper::class),
\OC::$server->query(StackMapper::class),
$this->boardMapper = new BoardMapper(
$this->dbConnection,
\OC::$server->query(LabelMapper::class),
\OC::$server->query(AclMapper::class),
\OC::$server->query(StackMapper::class),
$this->userManager,
$this->groupManager
);
$this->aclMapper = \OC::$server->query(AclMapper::class);
$this->labelMapper = \OC::$server->query(LabelMapper::class);
);
$this->aclMapper = \OC::$server->query(AclMapper::class);
$this->labelMapper = \OC::$server->query(LabelMapper::class);
$this->boards = [
$this->boardMapper->insert($this->getBoard('MyBoard 1', 'user1')),
$this->boardMapper->insert($this->getBoard('MyBoard 2', 'user2')),
$this->boardMapper->insert($this->getBoard('MyBoard 3', 'user3'))
];
$this->boards = [
$this->boardMapper->insert($this->getBoard('MyBoard 1', 'user1')),
$this->boardMapper->insert($this->getBoard('MyBoard 2', 'user2')),
$this->boardMapper->insert($this->getBoard('MyBoard 3', 'user3'))
];
$this->acls = [
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[1]->getId())),
$this->aclMapper->insert($this->getAcl('user','user2', true, false, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user3', true, true, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[2]->getId()))
];
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[1]->getId())),
$this->aclMapper->insert($this->getAcl('user','user2', true, false, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user3', true, true, false, $this->boards[0]->getId())),
$this->aclMapper->insert($this->getAcl('user','user1', false, false, false, $this->boards[2]->getId()))
];
foreach ($this->acls as $acl) {
$acl->resetUpdatedFields();
}
foreach ($this->boards as $board) {
$board->resetUpdatedFields();
}
$acl->resetUpdatedFields();
}
foreach ($this->boards as $board) {
$board->resetUpdatedFields();
}
}
/** @return Acl */
public function getAcl($type='user', $participant='admin', $edit=false, $share=false, $manage=false, $boardId=123) {
@@ -99,20 +99,20 @@ class BoardMapperTest extends MapperTestUtility {
/** @return Board */
public function getBoard($title, $owner) {
$board = new Board();
$board->setTitle($title);
$board->setOwner($owner);
return $board;
}
$board = new Board();
$board->setTitle($title);
$board->setOwner($owner);
return $board;
}
public function testFind() {
$actual = $this->boardMapper->find($this->boards[0]->getId());
/** @var Board $expected */
$expected = clone $this->boards[0];
$expected->setShared(-1);
$expected->resetUpdatedFields();
$this->assertEquals($expected, $actual);
}
$actual = $this->boardMapper->find($this->boards[0]->getId());
/** @var Board $expected */
$expected = clone $this->boards[0];
$expected->setShared(-1);
$expected->resetUpdatedFields();
$this->assertEquals($expected, $actual);
}
public function testFindAllByUser() {
$actual = $this->boardMapper->findAllByUser('user1');
@@ -123,7 +123,7 @@ class BoardMapperTest extends MapperTestUtility {
];
foreach ($expected as $e) {
foreach ($actual as $a) {
if($e->getId() === $a->getId()) {
if ($e->getId() === $a->getId()) {
$this->assertEquals($e->getTitle(), $a->getTitle());
}
}
@@ -149,27 +149,26 @@ class BoardMapperTest extends MapperTestUtility {
$this->boardMapper->update($this->boards[0]);
}
public function testFindWithLabels() {
$actual = $this->boardMapper->find($this->boards[0]->getId(), true, false);
public function testFindWithLabels() {
$actual = $this->boardMapper->find($this->boards[0]->getId(), true, false);
/** @var Board $expected */
$expected = $this->boards[0];
$this->assertEquals($expected->getLabels(), $actual->getLabels());
}
$this->assertEquals($expected->getLabels(), $actual->getLabels());
}
public function testFindWithAcl() {
$actual = $this->boardMapper->find($this->boards[0]->getId(), false, true);
$expected = [$this->acls[1], $this->acls[2]];
$this->assertEquals($expected, $actual->getAcl());
}
public function tearDown(): void {
parent::tearDown();
foreach ($this->acls as $acl) {
$this->aclMapper->delete($acl);
}
foreach ($this->boards as $board) {
$this->boardMapper->delete($board);
}
}
public function testFindWithAcl() {
$actual = $this->boardMapper->find($this->boards[0]->getId(), false, true);
$expected = [$this->acls[1], $this->acls[2]];
$this->assertEquals($expected, $actual->getAcl());
}
public function tearDown(): void {
parent::tearDown();
foreach ($this->acls as $acl) {
$this->aclMapper->delete($acl);
}
foreach ($this->boards as $board) {
$this->boardMapper->delete($board);
}
}
}

View File

@@ -23,12 +23,12 @@ class BoardTest extends TestCase {
'title' => "My Board",
'owner' => "admin",
'color' => "000000",
'labels' => array(),
'labels' => [],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => array(),
'acl' => [],
'archived' => false,
'users' => ['user1', 'user2'],
], $board->jsonSerialize());
@@ -36,18 +36,18 @@ class BoardTest extends TestCase {
public function testSetLabels() {
$board = $this->createBoard();
$board->setLabels(array("foo", "bar"));
$board->setLabels(["foo", "bar"]);
$this->assertEquals([
'id' => 1,
'title' => "My Board",
'owner' => "admin",
'color' => "000000",
'labels' => array("foo", "bar"),
'labels' => ["foo", "bar"],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => array(),
'acl' => [],
'archived' => false,
'users' => [],
], $board->jsonSerialize());
@@ -56,7 +56,7 @@ class BoardTest extends TestCase {
$acl = new Acl();
$acl->setId(1);
$board = $this->createBoard();
$board->setAcl(array($acl));
$board->setAcl([$acl]);
$result = $board->getAcl()[0];
$this->assertEquals($acl, $result);
}
@@ -68,12 +68,12 @@ class BoardTest extends TestCase {
'title' => "My Board",
'owner' => "admin",
'color' => "000000",
'labels' => array(),
'labels' => [],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => array(),
'acl' => [],
'archived' => false,
'shared' => 1,
'users' => [],

View File

@@ -88,7 +88,7 @@ class CardTest extends TestCase {
}
public function testJsonSerializeLabels() {
$card = $this->createCard();
$card->setLabels(array());
$card->setLabels([]);
$this->assertEquals([
'id' => 1,
'title' => "My Card",
@@ -99,7 +99,7 @@ class CardTest extends TestCase {
'owner' => 'admin',
'order' => 12,
'stackId' => 1,
'labels' => array(),
'labels' => [],
'duedate' => null,
'overdue' => 0,
'archived' => false,
@@ -123,7 +123,7 @@ class CardTest extends TestCase {
public function testJsonSerializeAsignedUsers() {
$card = $this->createCard();
$card->setAssignedUsers([ 'user1' ]);
$card->setLabels(array());
$card->setLabels([]);
$this->assertEquals([
'id' => 1,
'title' => "My Card",
@@ -134,7 +134,7 @@ class CardTest extends TestCase {
'owner' => 'admin',
'order' => 12,
'stackId' => 1,
'labels' => array(),
'labels' => [],
'duedate' => null,
'overdue' => 0,
'archived' => false,
@@ -146,5 +146,4 @@ class CardTest extends TestCase {
'lastEditor' => null,
], $card->jsonSerialize());
}
}

View File

@@ -26,7 +26,6 @@ namespace OCA\Deck\Db;
use OCP\IGroup;
class GroupTest extends \Test\TestCase {
public function testGroupObjectSerialize() {
/** @var IGroup $group */
$group = $this->createMock(IGroup::class);

View File

@@ -5,20 +5,20 @@
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Db;
@@ -37,14 +37,13 @@ class LabelTest extends TestCase {
$label = $this->createLabel();
$label->setBoardId(123);
$this->assertEquals([
'id' => 1,
'title' => 'My Label',
'boardId' => 123,
'cardId' => null,
'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
'id' => 1,
'title' => 'My Label',
'boardId' => 123,
'cardId' => null,
'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
}
public function testJsonSerializeCard() {
$label = $this->createLabel();
@@ -57,8 +56,5 @@ class LabelTest extends TestCase {
'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
}
}

View File

@@ -5,26 +5,25 @@
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Db;
class RelationalEntityTest extends \Test\TestCase {
public function testRelation() {
$entity = new RelationalEntity();
$entity->foo = null;
@@ -48,5 +47,4 @@ class RelationalEntityTest extends \Test\TestCase {
];
$this->assertEquals($json, $entity->jsonSerialize());
}
}
}

View File

@@ -44,7 +44,7 @@ class StackTest extends \Test\TestCase {
], $board->jsonSerialize());
}
public function testJsonSerializeWithCards() {
$cards = array("foo", "bar");
$cards = ["foo", "bar"];
$board = $this->createStack();
$board->setCards($cards);
$this->assertEquals([
@@ -52,7 +52,7 @@ class StackTest extends \Test\TestCase {
'title' => "My Stack",
'order' => 1,
'boardId' => 1,
'cards' => array("foo", "bar"),
'cards' => ["foo", "bar"],
'deletedAt' => 0,
'lastModified' => 0,
], $board->jsonSerialize());

View File

@@ -26,7 +26,6 @@ namespace OCA\Deck\Db;
use OCP\IUser;
class UserTest extends \Test\TestCase {
public function testGroupObjectSerialize() {
/** @var IUser $user */
$user = $this->createMock(IUser::class);