Fix code style
Signed-off-by: Sergey Shliakhov <husband.sergey@gmail.com>
This commit is contained in:
committed by
Julius Härtl
parent
118959795f
commit
b8b3ac3516
@@ -9,11 +9,9 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
final class TransferOwnership extends Command {
|
||||
|
||||
protected $boardService;
|
||||
|
||||
public function __construct(BoardService $boardService)
|
||||
{
|
||||
public function __construct(BoardService $boardService) {
|
||||
parent::__construct();
|
||||
|
||||
$this->boardService = $boardService;
|
||||
@@ -45,5 +43,4 @@ final class TransferOwnership extends Command {
|
||||
|
||||
$output->writeln("Transfer deck entities from $owner to $newOwner completed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,8 +63,7 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
|
||||
* @param $newOwnerId
|
||||
* @return void
|
||||
*/
|
||||
public function transferOwnership($ownerId, $newOwnerId)
|
||||
{
|
||||
public function transferOwnership($ownerId, $newOwnerId) {
|
||||
$params = [
|
||||
'owner' => $ownerId,
|
||||
'newOwner' => $newOwnerId,
|
||||
|
||||
@@ -152,8 +152,7 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
|
||||
* @param $newOwnerId
|
||||
* @return void
|
||||
*/
|
||||
public function transferOwnership($ownerId, $newOwnerId)
|
||||
{
|
||||
public function transferOwnership($ownerId, $newOwnerId) {
|
||||
$params = [
|
||||
'owner' => $ownerId,
|
||||
'newOwner' => $newOwnerId
|
||||
|
||||
@@ -304,19 +304,18 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ownerId
|
||||
* @param $newOwnerId
|
||||
* @return void
|
||||
*/
|
||||
public function transferOwnership($ownerId, $newOwnerId)
|
||||
{
|
||||
$params = [
|
||||
'owner' => $ownerId,
|
||||
'newOwner' => $newOwnerId
|
||||
];
|
||||
$sql = "UPDATE `{$this->tableName}` SET `owner` = :newOwner WHERE `owner` = :owner";
|
||||
$stmt = $this->execute($sql, $params);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
/**
|
||||
* @param $ownerId
|
||||
* @param $newOwnerId
|
||||
* @return void
|
||||
*/
|
||||
public function transferOwnership($ownerId, $newOwnerId) {
|
||||
$params = [
|
||||
'owner' => $ownerId,
|
||||
'newOwner' => $newOwnerId
|
||||
];
|
||||
$sql = "UPDATE `{$this->tableName}` SET `owner` = :newOwner WHERE `owner` = :owner";
|
||||
$stmt = $this->execute($sql, $params);
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,8 +570,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
||||
* @param $newOwnerId
|
||||
* @return void
|
||||
*/
|
||||
public function transferOwnership($ownerId, $newOwnerId)
|
||||
{
|
||||
public function transferOwnership($ownerId, $newOwnerId) {
|
||||
$params = [
|
||||
'owner' => $ownerId,
|
||||
'newOwner' => $newOwnerId
|
||||
|
||||
@@ -680,8 +680,7 @@ class BoardService {
|
||||
* @param $newOwnerId
|
||||
* @return void
|
||||
*/
|
||||
public function transferOwnership($owner, $newOwner)
|
||||
{
|
||||
public function transferOwnership($owner, $newOwner) {
|
||||
$this->boardMapper->transferOwnership($owner, $newOwner);
|
||||
$this->assignedUsersMapper->transferOwnership($owner, $newOwner);
|
||||
$this->aclMapper->transferOwnership($owner, $newOwner);
|
||||
|
||||
@@ -25,12 +25,12 @@ class AssignedUsersMapperTest extends \Test\TestCase {
|
||||
protected $assignedUsersMapper;
|
||||
/** @var AssignmentService */
|
||||
private $assignmentService;
|
||||
/** @var Board */
|
||||
private $board;
|
||||
private $cards;
|
||||
private $stacks;
|
||||
/** @var Board */
|
||||
private $board;
|
||||
private $cards;
|
||||
private $stacks;
|
||||
|
||||
public static function setUpBeforeClass(): void {
|
||||
public static function setUpBeforeClass(): void {
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
$backend = new \Test\Util\User\Dummy();
|
||||
@@ -60,82 +60,77 @@ class AssignedUsersMapperTest extends \Test\TestCase {
|
||||
$stacks = [];
|
||||
$board = $this->boardService->create('Test', self::TEST_OWNER, '000000');
|
||||
$id = $board->getId();
|
||||
$this->boardService->addAcl($id, Acl::PERMISSION_TYPE_USER, self::TEST_OWNER, true, true, true);
|
||||
$this->boardService->addAcl($id, Acl::PERMISSION_TYPE_GROUP, self::TEST_GROUP, true, true, true);
|
||||
$this->boardService->addAcl($id, Acl::PERMISSION_TYPE_USER, self::TEST_OWNER, true, true, true);
|
||||
$this->boardService->addAcl($id, Acl::PERMISSION_TYPE_GROUP, self::TEST_GROUP, true, true, true);
|
||||
$stacks[] = $this->stackService->create('Stack A', $id, 1);
|
||||
$stacks[] = $this->stackService->create('Stack B', $id, 1);
|
||||
$stacks[] = $this->stackService->create('Stack C', $id, 1);
|
||||
$cards[] = $this->cardService->create('Card 1', $stacks[0]->getId(), 'text', 0, self::TEST_OWNER);
|
||||
$cards[] = $this->cardService->create('Card 2', $stacks[0]->getId(), 'text', 0, self::TEST_OWNER);
|
||||
$this->assignmentService->assignUser($cards[0]->getId(), self::TEST_OWNER);
|
||||
$this->board = $board;
|
||||
$this->assignmentService->assignUser($cards[0]->getId(), self::TEST_OWNER);
|
||||
$this->board = $board;
|
||||
$this->cards = $cards;
|
||||
$this->stacks = $stacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTransferBoardOwnership()
|
||||
{
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$board = $this->boardService->find($this->board->getId());
|
||||
$boardOwner = $board->getOwner();
|
||||
$this->assertEquals(self::TEST_NEW_OWNER, $boardOwner);
|
||||
}
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTransferBoardOwnership() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$board = $this->boardService->find($this->board->getId());
|
||||
$boardOwner = $board->getOwner();
|
||||
$this->assertEquals(self::TEST_NEW_OWNER, $boardOwner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTransferACLOwnership()
|
||||
{
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$board = $this->boardService->find($this->board->getId());
|
||||
$acl = $board->getAcl();
|
||||
$isTargetInAcl = (bool)array_filter($acl, function ($item) {
|
||||
return $item->getParticipant() === self::TEST_NEW_OWNER && $item->getType() === Acl::PERMISSION_TYPE_USER;
|
||||
});
|
||||
$this->assertTrue($isTargetInAcl);
|
||||
}
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTransferACLOwnership() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$board = $this->boardService->find($this->board->getId());
|
||||
$acl = $board->getAcl();
|
||||
$isTargetInAcl = (bool)array_filter($acl, function ($item) {
|
||||
return $item->getParticipant() === self::TEST_NEW_OWNER && $item->getType() === Acl::PERMISSION_TYPE_USER;
|
||||
});
|
||||
$this->assertTrue($isTargetInAcl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testNoTransferAclOwnershipIfGroupType()
|
||||
{
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$board = $this->boardService->find($this->board->getId());
|
||||
$acl = $board->getAcl();
|
||||
$isGroupInAcl = (bool)array_filter($acl, function ($item) {
|
||||
return $item->getParticipant() === self::TEST_GROUP && $item->getType() === Acl::PERMISSION_TYPE_GROUP;
|
||||
});
|
||||
$this->assertTrue($isGroupInAcl);
|
||||
}
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTransferCardOwnership()
|
||||
{
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$card = $this->cardService->find($this->cards[0]->getId());
|
||||
$cardOwner = $card->getOwner();
|
||||
$this->assertEquals(self::TEST_NEW_OWNER, $cardOwner);
|
||||
}
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testNoTransferAclOwnershipIfGroupType() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$board = $this->boardService->find($this->board->getId());
|
||||
$acl = $board->getAcl();
|
||||
$isGroupInAcl = (bool)array_filter($acl, function ($item) {
|
||||
return $item->getParticipant() === self::TEST_GROUP && $item->getType() === Acl::PERMISSION_TYPE_GROUP;
|
||||
});
|
||||
$this->assertTrue($isGroupInAcl);
|
||||
}
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testTransferCardOwnership() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$card = $this->cardService->find($this->cards[0]->getId());
|
||||
$cardOwner = $card->getOwner();
|
||||
$this->assertEquals(self::TEST_NEW_OWNER, $cardOwner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testReassignCardToNewOwner()
|
||||
{
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$assignedUsers = $this->assignedUsersMapper->find($this->cards[0]->getId());
|
||||
$participantsUIDs = [];
|
||||
foreach ($assignedUsers as $user) {
|
||||
$participantsUIDs[] = $user->getParticipant();
|
||||
}
|
||||
$this->assertContains(self::TEST_NEW_OWNER, $participantsUIDs);
|
||||
$this->assertNotContains(self::TEST_OWNER, $participantsUIDs);
|
||||
}
|
||||
/**
|
||||
* @covers ::transferOwnership
|
||||
*/
|
||||
public function testReassignCardToNewOwner() {
|
||||
$this->boardService->transferOwnership(self::TEST_OWNER, self::TEST_NEW_OWNER);
|
||||
$assignedUsers = $this->assignedUsersMapper->find($this->cards[0]->getId());
|
||||
$participantsUIDs = [];
|
||||
foreach ($assignedUsers as $user) {
|
||||
$participantsUIDs[] = $user->getParticipant();
|
||||
}
|
||||
$this->assertContains(self::TEST_NEW_OWNER, $participantsUIDs);
|
||||
$this->assertNotContains(self::TEST_OWNER, $participantsUIDs);
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
$this->boardService->deleteForce($this->board->getId());
|
||||
|
||||
Reference in New Issue
Block a user