From 11bd0bed0d0b755b7e058e112eb57b7e80b057a4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 24 Nov 2020 17:31:20 +0100 Subject: [PATCH] remove some getter/setter --- Controller/ApiController.php | 34 +++---- Controller/BackendController.php | 16 +-- Models/KanbanBoard.php | 98 +------------------ Models/KanbanCard.php | 98 +------------------ Models/KanbanCardComment.php | 70 +------------ Models/KanbanColumn.php | 28 +----- Theme/Backend/kanban-board.tpl.php | 6 +- Theme/Backend/kanban-card.tpl.php | 6 +- Theme/Backend/kanban-dashboard.tpl.php | 4 +- tests/ControllerTest.php | 12 +-- tests/Models/1KanbanBoardMapperTest.php | 20 ++-- tests/Models/3KanbanColumnMapperTest.php | 6 +- tests/Models/4KanbanCardMapperTest.php | 22 ++--- tests/Models/5KanbanCardCommentMapperTest.php | 14 +-- tests/Models/KanbanBoardTest.php | 20 ++-- tests/Models/KanbanCardCommentTest.php | 14 +-- tests/Models/KanbanCardTest.php | 20 ++-- tests/Models/KanbanColumnTest.php | 6 +- 18 files changed, 112 insertions(+), 382 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 039a428..2f8f4c0 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -63,13 +63,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateKanbanCardCreate($request))) { $response->set('kanban_card_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $card = $this->createKanbanCardFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $card, KanbanCardMapper::class, 'card', $request->getOrigin()); + $this->createModel($request->header->account, $card, KanbanCardMapper::class, 'card', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Card', 'Card successfully created.', $card); } @@ -85,14 +85,14 @@ final class ApiController extends Controller public function createKanbanCardFromRequest(RequestAbstract $request) : KanbanCard { $card = new KanbanCard(); - $card->setName((string) ($request->getData('title'))); - $card->setDescription((string) ($request->getData('plain') ?? '')); + $card->name = (string) ($request->getData('title')); + $card->description = (string) ($request->getData('plain') ?? ''); $card->setColumn((int) $request->getData('column')); $card->setOrder((int) ($request->getData('order') ?? 1)); $card->setRef((int) ($request->getData('ref') ?? 0)); $card->setStatus((int) ($request->getData('status') ?? CardStatus::ACTIVE)); $card->setType((int) ($request->getData('type') ?? CardType::TEXT)); - $card->setCreatedBy(new NullAccount($request->getHeader()->getAccount())); + $card->createdBy = new NullAccount($request->header->account); return $card; } @@ -143,13 +143,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateKanbanCardCommentCreate($request))) { $response->set('kanban_comment_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $comment = $this->createKanbanCardCommentFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $comment, KanbanCardCommentMapper::class, 'comment', $request->getOrigin()); + $this->createModel($request->header->account, $comment, KanbanCardCommentMapper::class, 'comment', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Card', 'Card successfully created.', $comment); } @@ -165,9 +165,9 @@ final class ApiController extends Controller public function createKanbanCardCommentFromRequest(RequestAbstract $request) : KanbanCardComment { $comment = new KanbanCardComment(); - $comment->setDescription((string) ($request->getData('plain') ?? '')); + $comment->description = (string) ($request->getData('plain') ?? ''); $comment->setCard((int) $request->getData('card')); - $comment->setCreatedBy(new NullAccount($request->getHeader()->getAccount())); + $comment->createdBy = new NullAccount($request->header->account); return $comment; } @@ -210,13 +210,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateKanbanBoardCreate($request))) { $response->set('kanban_board_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $board = $this->createKanbanBoardFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $board, KanbanBoardMapper::class, 'board',$request->getOrigin()); + $this->createModel($request->header->account, $board, KanbanBoardMapper::class, 'board',$request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully created.', $board); } @@ -232,11 +232,11 @@ final class ApiController extends Controller public function createKanbanBoardFromRequest(RequestAbstract $request) : KanbanBoard { $board = new KanbanBoard(); - $board->setName((string) $request->getData('title')); - $board->setDescription((string) ($request->getData('plain') ?? '')); + $board->name = (string) $request->getData('title'); + $board->description = (string) ($request->getData('plain') ?? ''); $board->setOrder((int) ($request->getData('order') ?? 1)); $board->setStatus((int) ($request->getData('status') ?? BoardStatus::ACTIVE)); - $board->setCreatedBy(new NullAccount($request->getHeader()->getAccount())); + $board->createdBy = new NullAccount($request->header->account); return $board; } @@ -282,13 +282,13 @@ final class ApiController extends Controller { if (!empty($val = $this->validateKanbanColumnCreate($request))) { $response->set('kanban_column_create', new FormValidation($val)); - $response->getHeader()->setStatusCode(RequestStatusCode::R_400); + $response->header->status = RequestStatusCode::R_400; return; } $column = $this->createKanbanColumnFromRequest($request); - $this->createModel($request->getHeader()->getAccount(), $column, KanbanColumnMapper::class, 'column', $request->getOrigin()); + $this->createModel($request->header->account, $column, KanbanColumnMapper::class, 'column', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Column', 'Column successfully created.', $column); } @@ -304,7 +304,7 @@ final class ApiController extends Controller public function createKanbanColumnFromRequest(RequestAbstract $request) : KanbanColumn { $column = new KanbanColumn(); - $column->setName((string) $request->getData('title')); + $column->name = (string) $request->getData('title'); $column->setBoard((int) $request->getData('board')); $column->setOrder((int) ($request->getData('order') ?? 1)); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 69f36d5..6a5ab52 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -103,14 +103,14 @@ final class BackendController extends Controller $view = new View($this->app->l11nManager, $request, $response); $board = KanbanBoardMapper::get((int) $request->getData('id')); - $accountId = $request->getHeader()->getAccount(); + $accountId = $request->header->account; - if ($board->getCreatedBy()->getId() !== $accountId + if ($board->createdBy->getId() !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( PermissionType::READ, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::BOARD, $board->getId()) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); - $response->getHeader()->setStatusCode(RequestStatusCode::R_403); + $response->header->status = RequestStatusCode::R_403; return $view; } @@ -158,13 +158,13 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); - $accountId = $request->getHeader()->getAccount(); + $accountId = $request->header->account; if (!$this->app->accountManager->get($accountId)->hasPermission( PermissionType::CREATE, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::BOARD) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); - $response->getHeader()->setStatusCode(RequestStatusCode::R_403); + $response->header->status = RequestStatusCode::R_403; return $view; } @@ -191,14 +191,14 @@ final class BackendController extends Controller $view = new View($this->app->l11nManager, $request, $response); $card = KanbanCardMapper::get((int) $request->getData('id')); - $accountId = $request->getHeader()->getAccount(); + $accountId = $request->header->account; - if ($card->getCreatedBy()->getId() !== $accountId + if ($card->createdBy->getId() !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( PermissionType::READ, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::CARD, $card->getId()) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); - $response->getHeader()->setStatusCode(RequestStatusCode::R_403); + $response->header->status = RequestStatusCode::R_403; return $view; } diff --git a/Models/KanbanBoard.php b/Models/KanbanBoard.php index 2f132f7..b7f54fb 100755 --- a/Models/KanbanBoard.php +++ b/Models/KanbanBoard.php @@ -41,7 +41,7 @@ class KanbanBoard implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; private int $status = BoardStatus::ACTIVE; @@ -53,11 +53,11 @@ class KanbanBoard implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $description = ''; + public string $description = ''; - private Account $createdBy; + public Account $createdBy; - private \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; private array $columns = []; @@ -84,32 +84,6 @@ class KanbanBoard implements \JsonSerializable return $this->id; } - /** - * Get name - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name - * - * @param string $name Name - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - /** * Get the status * @@ -162,70 +136,6 @@ class KanbanBoard implements \JsonSerializable $this->order = $order; } - /** - * Get description - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description - * - * @param string $description Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription(string $description) : void - { - $this->description = $description; - } - - /** - * Get created by - * - * @return Account - * - * @since 1.0.0 - */ - public function getCreatedBy() : Account - { - return $this->createdBy; - } - - /** - * Set created by - * - * @param Account $account Created by - * - * @return void - * - * @since 1.0.0 - */ - public function setCreatedBy(Account $account) : void - { - $this->createdBy = $account; - } - - /** - * Get created at date time - * - * @return \DateTimeImmutable - * - * @since 1.0.0 - */ - public function getCreatedAt() : \DateTimeImmutable - { - return $this->createdAt; - } - /** * Get the columns * diff --git a/Models/KanbanCard.php b/Models/KanbanCard.php index e825099..af18dab 100755 --- a/Models/KanbanCard.php +++ b/Models/KanbanCard.php @@ -42,7 +42,7 @@ class KanbanCard implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; private int $status = CardStatus::ACTIVE; @@ -54,7 +54,7 @@ class KanbanCard implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $description = ''; + public string $description = ''; private $column = 0; @@ -62,9 +62,9 @@ class KanbanCard implements \JsonSerializable private $ref = 0; - private Account $createdBy; + public Account $createdBy; - private \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; private array $comments = []; @@ -147,32 +147,6 @@ class KanbanCard implements \JsonSerializable return $this->column; } - /** - * Get name - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name - * - * @param string $name Name - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - /** * Get the status * @@ -251,70 +225,6 @@ class KanbanCard implements \JsonSerializable $this->ref = $ref; } - /** - * Get description - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description - * - * @param string $description Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription(string $description) : void - { - $this->description = $description; - } - - /** - * Get created by - * - * @return Account - * - * @since 1.0.0 - */ - public function getCreatedBy() : Account - { - return $this->createdBy; - } - - /** - * Set created by - * - * @param Account $account Created by - * - * @return void - * - * @since 1.0.0 - */ - public function setCreatedBy(Account $account) : void - { - $this->createdBy = $account; - } - - /** - * Get created at date time - * - * @return \DateTimeImmutable - * - * @since 1.0.0 - */ - public function getCreatedAt() : \DateTimeImmutable - { - return $this->createdAt; - } - /** * Get the comments * diff --git a/Models/KanbanCardComment.php b/Models/KanbanCardComment.php index f7ccd39..d623ba5 100755 --- a/Models/KanbanCardComment.php +++ b/Models/KanbanCardComment.php @@ -41,13 +41,13 @@ class KanbanCardComment implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $description = ''; + public string $description = ''; private $card = 0; - private Account $createdBy; + public Account $createdBy; - private \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; private array $media = []; @@ -100,70 +100,6 @@ class KanbanCardComment implements \JsonSerializable return $this->card; } - /** - * Get description - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description - * - * @param string $description Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription(string $description) : void - { - $this->description = $description; - } - - /** - * Get created by - * - * @return Account - * - * @since 1.0.0 - */ - public function getCreatedBy() : Account - { - return $this->createdBy; - } - - /** - * Set created by - * - * @param Account $account Created by - * - * @return void - * - * @since 1.0.0 - */ - public function setCreatedBy(Account $account) : void - { - $this->createdBy = $account; - } - - /** - * Get created at date time - * - * @return \DateTimeImmutable - * - * @since 1.0.0 - */ - public function getCreatedAt() : \DateTimeImmutable - { - return $this->createdAt; - } - /** * Get the media files * diff --git a/Models/KanbanColumn.php b/Models/KanbanColumn.php index 2563454..2c04607 100755 --- a/Models/KanbanColumn.php +++ b/Models/KanbanColumn.php @@ -38,7 +38,7 @@ class KanbanColumn implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Column order @@ -122,32 +122,6 @@ class KanbanColumn implements \JsonSerializable return $this->board; } - /** - * Get name - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name - * - * @param string $name Name - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - /** * Get the cards * diff --git a/Theme/Backend/kanban-board.tpl.php b/Theme/Backend/kanban-board.tpl.php index b0c11f1..059f13a 100755 --- a/Theme/Backend/kanban-board.tpl.php +++ b/Theme/Backend/kanban-board.tpl.php @@ -10,13 +10,13 @@ $columns = $board->getColumns();
getCards(); ?>
-
printHtml($column->getName()); ?>
+
printHtml($column->name); ?>
getLabels(); ?>
-

printHtml($card->getName()); ?>

+

printHtml($card->name); ?>

- printHtml($card->getDescription()); ?> + printHtml($card->description); ?> printHtml($label->getName()); ?> diff --git a/Theme/Backend/kanban-card.tpl.php b/Theme/Backend/kanban-card.tpl.php index f102aed..efc6d9f 100755 --- a/Theme/Backend/kanban-card.tpl.php +++ b/Theme/Backend/kanban-card.tpl.php @@ -6,9 +6,9 @@ $comments = $card->getComments();
-

printHtml($card->getName()); ?>

+

printHtml($card->name); ?>

- printHtml($card->getDescription()); ?> + printHtml($card->description); ?>
@@ -19,7 +19,7 @@ $comments = $card->getComments();
- printHtml($comment->getDescription()); ?> + printHtml($comment->description); ?>
diff --git a/Theme/Backend/kanban-dashboard.tpl.php b/Theme/Backend/kanban-dashboard.tpl.php index aebedef..69c1460 100755 --- a/Theme/Backend/kanban-dashboard.tpl.php +++ b/Theme/Backend/kanban-dashboard.tpl.php @@ -23,9 +23,9 @@ echo $this->getData('nav')->render(); ?>
-
printHtml($board->getName()); ?>
+
printHtml($board->name); ?>
- printHtml($board->getDescription()); ?> + printHtml($board->description); ?>
diff --git a/tests/ControllerTest.php b/tests/ControllerTest.php index 8b50751..61522f4 100755 --- a/tests/ControllerTest.php +++ b/tests/ControllerTest.php @@ -87,13 +87,13 @@ class ControllerTest extends \PHPUnit\Framework\TestCase $response = new HttpResponse(); $request = new HttpRequest(new HttpUri('')); - $request->getHeader()->setAccount(1); + $request->header->account = 1; $request->setData('title', 'Controller Test Board'); $request->setData('plain', 'Controller Test Description'); $this->module->apiKanbanBoardCreate($request, $response); - self::assertEquals('Controller Test Board', $response->get('')['response']->getName()); + self::assertEquals('Controller Test Board', $response->get('')['response']->name); self::assertGreaterThan(0, $response->get('')['response']->getId()); } @@ -106,13 +106,13 @@ class ControllerTest extends \PHPUnit\Framework\TestCase $response = new HttpResponse(); $request = new HttpRequest(new HttpUri('')); - $request->getHeader()->setAccount(1); + $request->header->account = 1; $request->setData('title', 'Controller Test Column'); $request->setData('board', 1); $this->module->apiKanbanColumnCreate($request, $response); - self::assertEquals('Controller Test Column', $response->get('')['response']->getName()); + self::assertEquals('Controller Test Column', $response->get('')['response']->name); self::assertGreaterThan(0, $response->get('')['response']->getId()); } @@ -125,14 +125,14 @@ class ControllerTest extends \PHPUnit\Framework\TestCase $response = new HttpResponse(); $request = new HttpRequest(new HttpUri('')); - $request->getHeader()->setAccount(1); + $request->header->account = 1; $request->setData('title', 'Controller Test Card'); $request->setData('plain', 'Controller Test Description'); $request->setData('column', '1'); $this->module->apiKanbanCardCreate($request, $response); - self::assertEquals('Controller Test Card', $response->get('')['response']->getName()); + self::assertEquals('Controller Test Card', $response->get('')['response']->name); self::assertGreaterThan(0, $response->get('')['response']->getId()); } } diff --git a/tests/Models/1KanbanBoardMapperTest.php b/tests/Models/1KanbanBoardMapperTest.php index 0a52ed9..82365f1 100755 --- a/tests/Models/1KanbanBoardMapperTest.php +++ b/tests/Models/1KanbanBoardMapperTest.php @@ -32,20 +32,20 @@ class KanbanBoardMapperTest extends \PHPUnit\Framework\TestCase { $board = new KanbanBoard(); - $board->setName('Test Board 0'); - $board->setDescription('This is some description'); - $board->setCreatedBy(new NullAccount(1)); + $board->name = 'Test Board 0'; + $board->description = 'This is some description'; + $board->createdBy = new NullAccount(1); $id = KanbanBoardMapper::create($board); self::assertGreaterThan(0, $board->getId()); self::assertEquals($id, $board->getId()); $boardR = KanbanBoardMapper::get($board->getId()); - self::assertEquals($board->getName(), $boardR->getName()); + self::assertEquals($board->name, $boardR->name); self::assertEquals($board->getStatus(), $boardR->getStatus()); - self::assertEquals($board->getDescription(), $boardR->getDescription()); - self::assertEquals($board->getCreatedBy()->getId(), $boardR->getCreatedBy()->getId()); - self::assertEquals($board->getCreatedAt()->format('Y-m-d'), $boardR->getCreatedAt()->format('Y-m-d')); + self::assertEquals($board->description, $boardR->description); + self::assertEquals($board->createdBy->getId(), $boardR->createdBy->getId()); + self::assertEquals($board->createdAt->format('Y-m-d'), $boardR->createdAt->format('Y-m-d')); self::assertEquals($board->getColumns(), $boardR->getColumns()); } @@ -60,9 +60,9 @@ class KanbanBoardMapperTest extends \PHPUnit\Framework\TestCase $text = new Text(); $board = new KanbanBoard(); - $board->setName($text->generateText(\mt_rand(3, 7))); - $board->setDescription($text->generateText(\mt_rand(20, 70))); - $board->setCreatedBy(new NullAccount(1)); + $board->name = $text->generateText(\mt_rand(3, 7)); + $board->description = $text->generateText(\mt_rand(20, 70)); + $board->createdBy = new NullAccount(1); $id = KanbanBoardMapper::create($board); } diff --git a/tests/Models/3KanbanColumnMapperTest.php b/tests/Models/3KanbanColumnMapperTest.php index a9f201e..5cf598b 100755 --- a/tests/Models/3KanbanColumnMapperTest.php +++ b/tests/Models/3KanbanColumnMapperTest.php @@ -31,7 +31,7 @@ class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase { $column = new KanbanColumn(); - $column->setName('Some Column'); + $column->name = 'Some Column'; $column->setBoard(1); $column->setOrder(1); @@ -40,7 +40,7 @@ class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase self::assertEquals($id, $column->getId()); $columnR = KanbanColumnMapper::get($column->getId()); - self::assertEquals($column->getName(), $columnR->getName()); + self::assertEquals($column->name, $columnR->name); self::assertEquals($column->getBoard(), $columnR->getBoard()); self::assertEquals($column->getOrder(), $columnR->getOrder()); } @@ -56,7 +56,7 @@ class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase $text = new Text(); $column = new KanbanColumn(); - $column->setName($text->generateText(\mt_rand(3, 7))); + $column->name = $text->generateText(\mt_rand(3, 7)); $column->setBoard(1); $column->setOrder($i + 1); diff --git a/tests/Models/4KanbanCardMapperTest.php b/tests/Models/4KanbanCardMapperTest.php index 9eea8f8..428d1db 100755 --- a/tests/Models/4KanbanCardMapperTest.php +++ b/tests/Models/4KanbanCardMapperTest.php @@ -34,13 +34,13 @@ class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase { $card = new KanbanCard(); - $card->setName('Some Card name'); - $card->setDescription('This is some card description'); + $card->name = 'Some Card name'; + $card->description = 'This is some card description'; $card->setStatus(CardStatus::ACTIVE); $card->setType(CardType::TEXT); $card->setOrder(1); $card->setColumn(1); - $card->setCreatedBy(new NullAccount(1)); + $card->createdBy = new NullAccount(1); $card->addLabel(1); $card->addLabel(2); @@ -49,14 +49,14 @@ class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase self::assertEquals($id, $card->getId()); $cardR = KanbanCardMapper::get($card->getId()); - self::assertEquals($card->getName(), $cardR->getName()); - self::assertEquals($card->getDescription(), $cardR->getDescription()); + self::assertEquals($card->name, $cardR->name); + self::assertEquals($card->description, $cardR->description); self::assertEquals($card->getColumn(), $cardR->getColumn()); self::assertEquals($card->getOrder(), $cardR->getOrder()); self::assertEquals($card->getStatus(), $cardR->getStatus()); self::assertEquals($card->getType(), $cardR->getType()); - self::assertEquals($card->getCreatedBy()->getId(), $cardR->getCreatedBy()->getId()); - self::assertEquals($card->getCreatedAt()->format('Y-m-d'), $cardR->getCreatedAt()->format('Y-m-d')); + self::assertEquals($card->createdBy->getId(), $cardR->createdBy->getId()); + self::assertEquals($card->createdAt->format('Y-m-d'), $cardR->createdAt->format('Y-m-d')); self::assertEquals($card->getRef(), $cardR->getRef()); } @@ -73,7 +73,7 @@ class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase $card->setRef(1); $card->setOrder(1); $card->setColumn(1); - $card->setCreatedBy(new NullAccount(1)); + $card->createdBy = new NullAccount(1); $card->addLabel(1); $card->addLabel(2); @@ -93,13 +93,13 @@ class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase $text = new Text(); $card = new KanbanCard(); - $card->setName($text->generateText(\mt_rand(3, 7))); - $card->setDescription($text->generateText(\mt_rand(20, 100))); + $card->name = $text->generateText(\mt_rand(3, 7)); + $card->description = $text->generateText(\mt_rand(20, 100)); $card->setStatus(CardStatus::ACTIVE); $card->setType(CardType::TEXT); $card->setOrder(\mt_rand(1, 10)); $card->setColumn(\mt_rand(1, 4)); - $card->setCreatedBy(new NullAccount(1)); + $card->createdBy = new NullAccount(1); $card->addLabel(2); $card->addLabel(3); diff --git a/tests/Models/5KanbanCardCommentMapperTest.php b/tests/Models/5KanbanCardCommentMapperTest.php index fb1cb22..f8d6b33 100755 --- a/tests/Models/5KanbanCardCommentMapperTest.php +++ b/tests/Models/5KanbanCardCommentMapperTest.php @@ -32,19 +32,19 @@ class KanbanCardCommentMapperTest extends \PHPUnit\Framework\TestCase { $comment = new KanbanCardComment(); - $comment->setDescription('This is some card description'); + $comment->description = 'This is some card description'; $comment->setCard(1); - $comment->setCreatedBy(new NullAccount(1)); + $comment->createdBy = new NullAccount(1); $id = KanbanCardCommentMapper::create($comment); self::assertGreaterThan(0, $comment->getId()); self::assertEquals($id, $comment->getId()); $commentR = KanbanCardCommentMapper::get($comment->getId()); - self::assertEquals($comment->getDescription(), $commentR->getDescription()); + self::assertEquals($comment->description, $commentR->description); self::assertEquals($comment->getCard(), $commentR->getCard()); - self::assertEquals($comment->getCreatedBy()->getId(), $commentR->getCreatedBy()->getId()); - self::assertEquals($comment->getCreatedAt()->format('Y-m-d'), $commentR->getCreatedAt()->format('Y-m-d')); + self::assertEquals($comment->createdBy->getId(), $commentR->createdBy->getId()); + self::assertEquals($comment->createdAt->format('Y-m-d'), $commentR->createdAt->format('Y-m-d')); } /** @@ -58,9 +58,9 @@ class KanbanCardCommentMapperTest extends \PHPUnit\Framework\TestCase $text = new Text(); $comment = new KanbanCardComment(); - $comment->setDescription($text->generateText(\mt_rand(20, 100))); + $comment->description = $text->generateText(\mt_rand(20, 100)); $comment->setCard(1); - $comment->setCreatedBy(new NullAccount(1)); + $comment->createdBy = new NullAccount(1); $id = KanbanCardCommentMapper::create($comment); } diff --git a/tests/Models/KanbanBoardTest.php b/tests/Models/KanbanBoardTest.php index d82645f..821f433 100755 --- a/tests/Models/KanbanBoardTest.php +++ b/tests/Models/KanbanBoardTest.php @@ -33,10 +33,10 @@ class KanbanBoardTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $board->getId()); self::assertEquals(BoardStatus::ACTIVE, $board->getStatus()); - self::assertEquals('', $board->getName()); - self::assertEquals('', $board->getDescription()); - self::assertEquals(0, $board->getCreatedBy()->getId()); - self::assertInstanceOf('\DateTimeImmutable', $board->getCreatedAt()); + self::assertEquals('', $board->name); + self::assertEquals('', $board->description); + self::assertEquals(0, $board->createdBy->getId()); + self::assertInstanceOf('\DateTimeImmutable', $board->createdAt); self::assertEquals([], $board->getColumns()); } @@ -48,16 +48,16 @@ class KanbanBoardTest extends \PHPUnit\Framework\TestCase { $board = new KanbanBoard(); - $board->setName('Name'); - $board->setDescription('Description'); + $board->name = 'Name'; + $board->description = 'Description'; $board->setStatus(BoardStatus::ARCHIVED); - $board->setCreatedBy(new NullAccount(1)); + $board->createdBy = new NullAccount(1); $board->addColumn(2); self::assertEquals(BoardStatus::ARCHIVED, $board->getStatus()); - self::assertEquals('Name', $board->getName()); - self::assertEquals('Description', $board->getDescription()); - self::assertEquals(1, $board->getCreatedBy()->getId()); + self::assertEquals('Name', $board->name); + self::assertEquals('Description', $board->description); + self::assertEquals(1, $board->createdBy->getId()); self::assertEquals([2], $board->getColumns()); } } diff --git a/tests/Models/KanbanCardCommentTest.php b/tests/Models/KanbanCardCommentTest.php index 7de6c55..82dce08 100755 --- a/tests/Models/KanbanCardCommentTest.php +++ b/tests/Models/KanbanCardCommentTest.php @@ -32,9 +32,9 @@ class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $comment->getId()); self::assertEquals(0, $comment->getCard()); - self::assertEquals('', $comment->getDescription()); - self::assertEquals(0, $comment->getCreatedBy()->getId()); - self::assertInstanceOf('\DateTimeImmutable', $comment->getCreatedAt()); + self::assertEquals('', $comment->description); + self::assertEquals(0, $comment->createdBy->getId()); + self::assertInstanceOf('\DateTimeImmutable', $comment->createdAt); self::assertEquals([], $comment->getMedia()); } @@ -47,13 +47,13 @@ class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase $comment = new KanbanCardComment(); $comment->setCard(2); - $comment->setDescription('Description'); - $comment->setCreatedBy(new NullAccount(1)); + $comment->description = 'Description'; + $comment->createdBy = new NullAccount(1); $comment->addMedia(3); self::assertEquals(2, $comment->getCard()); - self::assertEquals('Description', $comment->getDescription()); - self::assertEquals(1, $comment->getCreatedBy()->getId()); + self::assertEquals('Description', $comment->description); + self::assertEquals(1, $comment->createdBy->getId()); self::assertEquals([3], $comment->getMedia()); } } diff --git a/tests/Models/KanbanCardTest.php b/tests/Models/KanbanCardTest.php index 70b159a..2922e3e 100755 --- a/tests/Models/KanbanCardTest.php +++ b/tests/Models/KanbanCardTest.php @@ -35,12 +35,12 @@ class KanbanCardTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $card->getId()); self::assertEquals(CardStatus::ACTIVE, $card->getStatus()); self::assertEquals(CardType::TEXT, $card->getType()); - self::assertEquals('', $card->getName()); - self::assertEquals('', $card->getDescription()); + self::assertEquals('', $card->name); + self::assertEquals('', $card->description); self::assertEquals(0, $card->getColumn()); self::assertEquals(0, $card->getOrder()); - self::assertEquals(0, $card->getCreatedBy()->getId()); - self::assertInstanceOf('\DateTimeImmutable', $card->getCreatedAt()); + self::assertEquals(0, $card->createdBy->getId()); + self::assertInstanceOf('\DateTimeImmutable', $card->createdAt); self::assertEquals([], $card->getComments()); self::assertEquals([], $card->getLabels()); self::assertEquals([], $card->getMedia()); @@ -55,21 +55,21 @@ class KanbanCardTest extends \PHPUnit\Framework\TestCase $card = new KanbanCard(); $card->setStatus(CardStatus::ARCHIVED); $card->setType(CardType::TASK); - $card->setName('Name'); - $card->setDescription('Description'); + $card->name = 'Name'; + $card->description = 'Description'; $card->setColumn(1); $card->setOrder(2); - $card->setCreatedBy(new NullAccount(1)); + $card->createdBy = new NullAccount(1); $card->addComment(5); $card->addMedia(7); self::assertEquals(CardStatus::ARCHIVED, $card->getStatus()); self::assertEquals(CardType::TASK, $card->getType()); - self::assertEquals('Name', $card->getName()); - self::assertEquals('Description', $card->getDescription()); + self::assertEquals('Name', $card->name); + self::assertEquals('Description', $card->description); self::assertEquals(1, $card->getColumn()); self::assertEquals(2, $card->getOrder()); - self::assertEquals(1, $card->getCreatedBy()->getId()); + self::assertEquals(1, $card->createdBy->getId()); self::assertEquals([5], $card->getComments()); self::assertEquals([7], $card->getMedia()); } diff --git a/tests/Models/KanbanColumnTest.php b/tests/Models/KanbanColumnTest.php index 2fe63f4..f0269a9 100755 --- a/tests/Models/KanbanColumnTest.php +++ b/tests/Models/KanbanColumnTest.php @@ -31,7 +31,7 @@ class KanbanColumnTest extends \PHPUnit\Framework\TestCase $column = new KanbanColumn(); self::assertEquals(0, $column->getId()); - self::assertEquals('', $column->getName()); + self::assertEquals('', $column->name); self::assertEquals(0, $column->getOrder()); self::assertEquals(0, $column->getBoard()); self::assertEquals([], $column->getCards()); @@ -45,12 +45,12 @@ class KanbanColumnTest extends \PHPUnit\Framework\TestCase { $column = new KanbanColumn(); - $column->setName('Name'); + $column->name = 'Name'; $column->setOrder(2); $column->setBoard(3); $column->addCard(new KanbanCard()); - self::assertEquals('Name', $column->getName()); + self::assertEquals('Name', $column->name); self::assertEquals(2, $column->getOrder()); self::assertEquals(3, $column->getBoard()); }