mirror of
https://github.com/Karaka-Management/oms-Kanban.git
synced 2026-02-15 11:48:40 +00:00
add tests
This commit is contained in:
parent
e67b4c953b
commit
1690b62a99
26
tests/Admin/AdminTest.php
Normal file
26
tests/Admin/AdminTest.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Admin;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AdminTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected const MODULE_NAME = 'Kanban';
|
||||
protected const URI_LOAD = 'http://127.0.0.1/en/backend/kanban';
|
||||
|
||||
use \Modules\tests\ModuleTestTrait;
|
||||
}
|
||||
140
tests/ControllerTest.php
Normal file
140
tests/ControllerTest.php
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban;
|
||||
|
||||
require_once __DIR__ . '/../Autoloader.php';
|
||||
|
||||
use Model\CoreSettings;
|
||||
use Modules\Admin\Models\AccountPermission;
|
||||
use phpOMS\Account\Account;
|
||||
use phpOMS\Account\AccountManager;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Dispatcher\Dispatcher;
|
||||
use phpOMS\Event\EventManager;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Module\ModuleManager;
|
||||
use phpOMS\Router\WebRouter;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
use phpOMS\Utils\TestUtils;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ControllerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected $app = null;
|
||||
protected $module = null;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->app = new class() extends ApplicationAbstract
|
||||
{
|
||||
protected string $appName = 'Api';
|
||||
};
|
||||
|
||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||
$this->app->orgId = 1;
|
||||
$this->app->appName = 'Backend';
|
||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||
$this->app->appSettings = new CoreSettings($this->app->dbPool->get());
|
||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules');
|
||||
$this->app->dispatcher = new Dispatcher($this->app);
|
||||
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
||||
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Web/Api/Hooks.php');
|
||||
|
||||
$account = new Account();
|
||||
TestUtils::setMember($account, 'id', 1);
|
||||
|
||||
$permission = new AccountPermission();
|
||||
$permission->setUnit(1);
|
||||
$permission->setApp('backend');
|
||||
$permission->setPermission(
|
||||
PermissionType::READ
|
||||
| PermissionType::CREATE
|
||||
| PermissionType::MODIFY
|
||||
| PermissionType::DELETE
|
||||
| PermissionType::PERMISSION
|
||||
);
|
||||
|
||||
$account->addPermission($permission);
|
||||
|
||||
$this->app->accountManager->add($account);
|
||||
$this->app->router = new WebRouter();
|
||||
|
||||
$this->module = $this->app->moduleManager->get('Kanban');
|
||||
|
||||
TestUtils::setMember($this->module, 'app', $this->app);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Kanban\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testCreateBoard() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(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::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Kanban\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testCreateColumn() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(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::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Kanban\Controller\ApiController
|
||||
* @group module
|
||||
*/
|
||||
public function testCreateCard() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(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::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
}
|
||||
66
tests/Models/1KanbanBoardMapperTest.php
Normal file
66
tests/Models/1KanbanBoardMapperTest.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Kanban\Models\KanbanBoard;
|
||||
use Modules\Kanban\Models\KanbanBoardMapper;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanBoardMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$board = new KanbanBoard();
|
||||
|
||||
$board->setName('Test Board 0');
|
||||
$board->setDescription('This is some description');
|
||||
$board->setCreatedBy(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->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->getColumns(), $boardR->getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 30; ++$i) {
|
||||
$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));
|
||||
|
||||
$id = KanbanBoardMapper::create($board);
|
||||
}
|
||||
}
|
||||
}
|
||||
62
tests/Models/3KanbanColumnMapperTest.php
Normal file
62
tests/Models/3KanbanColumnMapperTest.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Kanban\Models\KanbanColumn;
|
||||
use Modules\Kanban\Models\KanbanColumnMapper;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$column = new KanbanColumn();
|
||||
|
||||
$column->setName('Some Column');
|
||||
$column->setBoard(1);
|
||||
$column->setOrder(1);
|
||||
|
||||
$id = KanbanColumnMapper::create($column);
|
||||
self::assertGreaterThan(0, $column->getId());
|
||||
self::assertEquals($id, $column->getId());
|
||||
|
||||
$columnR = KanbanColumnMapper::get($column->getId());
|
||||
self::assertEquals($column->getName(), $columnR->getName());
|
||||
self::assertEquals($column->getBoard(), $columnR->getBoard());
|
||||
self::assertEquals($column->getOrder(), $columnR->getOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 4; ++$i) {
|
||||
$text = new Text();
|
||||
$column = new KanbanColumn();
|
||||
|
||||
$column->setName($text->generateText(\mt_rand(3, 7)));
|
||||
$column->setBoard(1);
|
||||
$column->setOrder($i + 1);
|
||||
|
||||
$id = KanbanColumnMapper::create($column);
|
||||
}
|
||||
}
|
||||
}
|
||||
101
tests/Models/4KanbanCardMapperTest.php
Normal file
101
tests/Models/4KanbanCardMapperTest.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Kanban\Models\CardStatus;
|
||||
use Modules\Kanban\Models\CardType;
|
||||
use Modules\Kanban\Models\KanbanCard;
|
||||
use Modules\Kanban\Models\KanbanCardMapper;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$card = new KanbanCard();
|
||||
|
||||
$card->setName('Some Card name');
|
||||
$card->setDescription('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->addLabel(1);
|
||||
$card->addLabel(2);
|
||||
|
||||
$id = KanbanCardMapper::create($card);
|
||||
self::assertGreaterThan(0, $card->getId());
|
||||
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->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->getRef(), $cardR->getRef());
|
||||
}
|
||||
|
||||
public function testTaskCard() : void
|
||||
{
|
||||
$card = new KanbanCard();
|
||||
|
||||
$card->setStatus(CardStatus::ACTIVE);
|
||||
$card->setType(CardType::TASK);
|
||||
$card->setRef(1);
|
||||
$card->setOrder(1);
|
||||
$card->setColumn(1);
|
||||
$card->setCreatedBy(new NullAccount(1));
|
||||
$card->addLabel(1);
|
||||
$card->addLabel(2);
|
||||
|
||||
$id = KanbanCardMapper::create($card);
|
||||
self::assertGreaterThan(0, $card->getId());
|
||||
self::assertEquals($id, $card->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 10; ++$i) {
|
||||
$text = new Text();
|
||||
$card = new KanbanCard();
|
||||
|
||||
$card->setName($text->generateText(\mt_rand(3, 7)));
|
||||
$card->setDescription($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->addLabel(2);
|
||||
$card->addLabel(3);
|
||||
|
||||
$id = KanbanCardMapper::create($card);
|
||||
}
|
||||
}
|
||||
}
|
||||
64
tests/Models/5KanbanCardCommentMapperTest.php
Normal file
64
tests/Models/5KanbanCardCommentMapperTest.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Kanban\Models\KanbanCardComment;
|
||||
use Modules\Kanban\Models\KanbanCardCommentMapper;
|
||||
use phpOMS\Utils\RnG\Text;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanCardCommentMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$comment = new KanbanCardComment();
|
||||
|
||||
$comment->setDescription('This is some card description');
|
||||
$comment->setCard(1);
|
||||
$comment->setCreatedBy(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->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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 10; ++$i) {
|
||||
$text = new Text();
|
||||
$comment = new KanbanCardComment();
|
||||
|
||||
$comment->setDescription($text->generateText(\mt_rand(20, 100)));
|
||||
$comment->setCard(1);
|
||||
$comment->setCreatedBy(new NullAccount(1));
|
||||
|
||||
$id = KanbanCardCommentMapper::create($comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
tests/Models/KanbanBoardTest.php
Normal file
55
tests/Models/KanbanBoardTest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Kanban\Models\BoardStatus;
|
||||
use Modules\Kanban\Models\KanbanBoard;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanBoardTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$board = new KanbanBoard();
|
||||
|
||||
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('\DateTime', $board->getCreatedAt());
|
||||
self::assertEquals([], $board->getColumns());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$board = new KanbanBoard();
|
||||
|
||||
$board->setName('Name');
|
||||
$board->setDescription('Description');
|
||||
$board->setStatus(BoardStatus::ARCHIVED);
|
||||
$board->setCreatedBy(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([2], $board->getColumns());
|
||||
}
|
||||
}
|
||||
51
tests/Models/KanbanCardCommentTest.php
Normal file
51
tests/Models/KanbanCardCommentTest.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Kanban\Models\KanbanCardComment;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$comment = new KanbanCardComment();
|
||||
|
||||
self::assertEquals(0, $comment->getId());
|
||||
self::assertEquals(0, $comment->getCard());
|
||||
self::assertEquals('', $comment->getDescription());
|
||||
self::assertEquals(0, $comment->getCreatedBy()->getId());
|
||||
self::assertInstanceOf('\DateTime', $comment->getCreatedAt());
|
||||
self::assertEquals([], $comment->getMedia());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$comment = new KanbanCardComment();
|
||||
|
||||
$comment->setCard(2);
|
||||
$comment->setDescription('Description');
|
||||
$comment->setCreatedBy(new NullAccount(1));
|
||||
$comment->addMedia(3);
|
||||
|
||||
self::assertEquals(2, $comment->getCard());
|
||||
self::assertEquals('Description', $comment->getDescription());
|
||||
self::assertEquals(1, $comment->getCreatedBy()->getId());
|
||||
self::assertEquals([3], $comment->getMedia());
|
||||
}
|
||||
}
|
||||
68
tests/Models/KanbanCardTest.php
Normal file
68
tests/Models/KanbanCardTest.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Kanban\Models\CardStatus;
|
||||
use Modules\Kanban\Models\CardType;
|
||||
use Modules\Kanban\Models\KanbanCard;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanCardTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$card = new KanbanCard();
|
||||
|
||||
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(0, $card->getColumn());
|
||||
self::assertEquals(0, $card->getOrder());
|
||||
self::assertEquals(0, $card->getCreatedBy()->getId());
|
||||
self::assertInstanceOf('\DateTime', $card->getCreatedAt());
|
||||
self::assertEquals([], $card->getComments());
|
||||
self::assertEquals([], $card->getLabels());
|
||||
self::assertEquals([], $card->getMedia());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$card = new KanbanCard();
|
||||
$card->setStatus(CardStatus::ARCHIVED);
|
||||
$card->setType(CardType::TASK);
|
||||
$card->setName('Name');
|
||||
$card->setDescription('Description');
|
||||
$card->setColumn(1);
|
||||
$card->setOrder(2);
|
||||
$card->setCreatedBy(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(1, $card->getColumn());
|
||||
self::assertEquals(2, $card->getOrder());
|
||||
self::assertEquals(1, $card->getCreatedBy()->getId());
|
||||
self::assertEquals([5], $card->getComments());
|
||||
self::assertEquals([7], $card->getMedia());
|
||||
}
|
||||
}
|
||||
49
tests/Models/KanbanColumnTest.php
Normal file
49
tests/Models/KanbanColumnTest.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\tests\Kanban\Models;
|
||||
|
||||
use Modules\Kanban\Models\KanbanCard;
|
||||
use Modules\Kanban\Models\KanbanColumn;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class KanbanColumnTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$column = new KanbanColumn();
|
||||
|
||||
self::assertEquals(0, $column->getId());
|
||||
self::assertEquals('', $column->getName());
|
||||
self::assertEquals(0, $column->getOrder());
|
||||
self::assertEquals(0, $column->getBoard());
|
||||
self::assertEquals([], $column->getCards());
|
||||
}
|
||||
|
||||
public function testSetGet() : void
|
||||
{
|
||||
$column = new KanbanColumn();
|
||||
|
||||
$column->setName('Name');
|
||||
$column->setOrder(2);
|
||||
$column->setBoard(3);
|
||||
$column->addCard(new KanbanCard());
|
||||
|
||||
self::assertEquals('Name', $column->getName());
|
||||
self::assertEquals(2, $column->getOrder());
|
||||
self::assertEquals(3, $column->getBoard());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user