cs fixes, bug fixes, code coverage

This commit is contained in:
Dennis Eichhorn 2021-11-16 00:05:43 +01:00
parent 833503241f
commit b345f1131f
15 changed files with 78 additions and 85 deletions

View File

@ -12,9 +12,7 @@ If you have a good idea for improvement feel free to create a new issue with all
### Issues ### Issues
Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the `Project.md` file in the `Docs` repository. Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the code marked with `@todo` or in the [PROJECT.md](https://github.com/Orange-Management/Docs/blob/master/Project/PROJECT.md) file.
The issue information can be used to provide additional information such as priority, difficulty and type. For your first issue try to find a issue marked `[d:first]` or `[d:beginner]`.
### Code Style ### Code Style

View File

@ -89,9 +89,9 @@ final class ApiController extends Controller
$card->descriptionRaw = (string) ($request->getData('plain') ?? ''); $card->descriptionRaw = (string) ($request->getData('plain') ?? '');
$card->description = Markdown::parse((string) ($request->getData('plain') ?? '')); $card->description = Markdown::parse((string) ($request->getData('plain') ?? ''));
$card->style = (string) ($request->getData('style') ?? ''); $card->style = (string) ($request->getData('style') ?? '');
$card->column = (int) $request->getData('column'); $card->column = (int) $request->getData('column');
$card->order = (int) ($request->getData('order') ?? 1); $card->order = (int) ($request->getData('order') ?? 1);
$card->ref = (int) ($request->getData('ref') ?? 0); $card->ref = (int) ($request->getData('ref') ?? 0);
$card->setStatus((int) ($request->getData('status') ?? CardStatus::ACTIVE)); $card->setStatus((int) ($request->getData('status') ?? CardStatus::ACTIVE));
$card->setType((int) ($request->getData('type') ?? CardType::TEXT)); $card->setType((int) ($request->getData('type') ?? CardType::TEXT));
$card->createdBy = new NullAccount($request->header->account); $card->createdBy = new NullAccount($request->header->account);
@ -207,8 +207,8 @@ final class ApiController extends Controller
$comment = new KanbanCardComment(); $comment = new KanbanCardComment();
$comment->description = Markdown::parse((string) ($request->getData('plain') ?? '')); $comment->description = Markdown::parse((string) ($request->getData('plain') ?? ''));
$comment->descriptionRaw = (string) ($request->getData('plain') ?? ''); $comment->descriptionRaw = (string) ($request->getData('plain') ?? '');
$comment->card = (int) $request->getData('card'); $comment->card = (int) $request->getData('card');
$comment->createdBy = new NullAccount($request->header->account); $comment->createdBy = new NullAccount($request->header->account);
if (!empty($uploadedFiles = $request->getFiles() ?? [])) { if (!empty($uploadedFiles = $request->getFiles() ?? [])) {
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles( $uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
@ -421,8 +421,8 @@ final class ApiController extends Controller
*/ */
public function createKanbanColumnFromRequest(RequestAbstract $request) : KanbanColumn public function createKanbanColumnFromRequest(RequestAbstract $request) : KanbanColumn
{ {
$column = new KanbanColumn(); $column = new KanbanColumn();
$column->name = (string) $request->getData('title'); $column->name = (string) $request->getData('title');
$column->board = (int) $request->getData('board'); $column->board = (int) $request->getData('board');
$column->order = (int) ($request->getData('order') ?? 1); $column->order = (int) ($request->getData('order') ?? 1);

View File

@ -16,8 +16,8 @@ namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account; use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Tag\Models\Tag;
use Modules\Tag\Models\NullTag; use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
/** /**
* Kanban board class. * Kanban board class.
@ -258,10 +258,10 @@ class KanbanBoard implements \JsonSerializable
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'status' => $this->status, 'status' => $this->status,
'columns' => $this->columns, 'columns' => $this->columns,
'tags' => $this->tags, 'tags' => $this->tags,
]; ];
} }

View File

@ -17,8 +17,8 @@ namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account; use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media; use Modules\Media\Models\Media;
use Modules\Tag\Models\Tag;
use Modules\Tag\Models\NullTag; use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
use Modules\Tasks\Models\Task; use Modules\Tasks\Models\Task;
/** /**
@ -364,19 +364,19 @@ class KanbanCard implements \JsonSerializable
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'title' => $this->name, 'title' => $this->name,
'description' => $this->description, 'description' => $this->description,
'descriptionRaw' => $this->descriptionRaw, 'descriptionRaw' => $this->descriptionRaw,
'status' => $this->status, 'status' => $this->status,
'type' => $this->type, 'type' => $this->type,
'column' => $this->column, 'column' => $this->column,
'order' => $this->order, 'order' => $this->order,
'ref' => $this->ref, 'ref' => $this->ref,
'createdBy' => $this->createdBy, 'createdBy' => $this->createdBy,
'createdAt' => $this->createdAt, 'createdAt' => $this->createdAt,
'comments' => $this->comments, 'comments' => $this->comments,
'media' => $this->media, 'media' => $this->media,
]; ];
} }

View File

@ -138,13 +138,13 @@ class KanbanCardComment implements \JsonSerializable
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'description' => $this->description, 'description' => $this->description,
'descriptionRaw' => $this->descriptionRaw, 'descriptionRaw' => $this->descriptionRaw,
'card' => $this->card, 'card' => $this->card,
'createdBy' => $this->createdBy, 'createdBy' => $this->createdBy,
'createdAt' => $this->createdAt, 'createdAt' => $this->createdAt,
'media' => $this->media, 'media' => $this->media,
]; ];
} }

View File

@ -128,11 +128,11 @@ class KanbanColumn implements \JsonSerializable
public function toArray() : array public function toArray() : array
{ {
return [ return [
'id' => $this->id, 'id' => $this->id,
'name' => $this->name, 'name' => $this->name,
'order' => $this->order, 'order' => $this->order,
'board' => $this->board, 'board' => $this->board,
'cards' => $this->cards, 'cards' => $this->cards,
]; ];
} }

View File

@ -24,13 +24,13 @@ use phpOMS\Dispatcher\Dispatcher;
use phpOMS\Event\EventManager; use phpOMS\Event\EventManager;
use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager; use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter; use phpOMS\Router\WebRouter;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri; use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils; use phpOMS\Utils\TestUtils;
use phpOMS\Module\ModuleAbstract;
use phpOMS\System\MimeType;
use phpOMS\Message\Http\RequestStatusCode;
/** /**
* @internal * @internal

View File

@ -17,7 +17,6 @@ namespace Modules\Kanban\tests\Models;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Kanban\Models\KanbanBoard; use Modules\Kanban\Models\KanbanBoard;
use Modules\Kanban\Models\KanbanBoardMapper; use Modules\Kanban\Models\KanbanBoardMapper;
use phpOMS\Utils\RnG\Text;
/** /**
* @internal * @internal

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Modules\Kanban\tests\Models; namespace Modules\Kanban\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\Kanban\Models\BoardStatus; use Modules\Kanban\Models\BoardStatus;
use Modules\Kanban\Models\KanbanBoard; use Modules\Kanban\Models\KanbanBoard;
use Modules\Tag\Models\Tag; use Modules\Tag\Models\Tag;
@ -107,10 +106,10 @@ final class KanbanBoardTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'status' => BoardStatus::ARCHIVED, 'status' => BoardStatus::ARCHIVED,
'columns' => [], 'columns' => [],
'tags' => [], 'tags' => [],
], ],
$serialized $serialized
); );

View File

@ -17,7 +17,6 @@ namespace Modules\Kanban\tests\Models;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Kanban\Models\KanbanCardComment; use Modules\Kanban\Models\KanbanCardComment;
use Modules\Kanban\Models\KanbanCardCommentMapper; use Modules\Kanban\Models\KanbanCardCommentMapper;
use phpOMS\Utils\RnG\Text;
/** /**
* @internal * @internal
@ -25,6 +24,7 @@ use phpOMS\Utils\RnG\Text;
final class KanbanCardCommentMapperTest extends \PHPUnit\Framework\TestCase final class KanbanCardCommentMapperTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @depends Modules\Kanban\tests\Models\KanbanCardMapperTest::testCRUD
* @covers Modules\Kanban\Models\KanbanCardCommentMapper * @covers Modules\Kanban\Models\KanbanCardCommentMapper
* @group module * @group module
*/ */
@ -33,8 +33,8 @@ final class KanbanCardCommentMapperTest extends \PHPUnit\Framework\TestCase
$comment = new KanbanCardComment(); $comment = new KanbanCardComment();
$comment->description = 'This is some card description'; $comment->description = 'This is some card description';
$comment->card = 1; $comment->card = 1;
$comment->createdBy = new NullAccount(1); $comment->createdBy = new NullAccount(1);
$id = KanbanCardCommentMapper::create($comment); $id = KanbanCardCommentMapper::create($comment);
self::assertGreaterThan(0, $comment->getId()); self::assertGreaterThan(0, $comment->getId());

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Modules\Kanban\tests\Models; namespace Modules\Kanban\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\Kanban\Models\KanbanCardComment; use Modules\Kanban\Models\KanbanCardComment;
use Modules\Media\Models\NullMedia; use Modules\Media\Models\NullMedia;
@ -63,9 +62,9 @@ final class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->comment->description = 'Description'; $this->comment->description = 'Description';
$this->comment->descriptionRaw = 'DescriptionRaw'; $this->comment->descriptionRaw = 'DescriptionRaw';
$this->comment->card = 2; $this->comment->card = 2;
$serialized = $this->comment->jsonSerialize(); $serialized = $this->comment->jsonSerialize();
unset($serialized['createdBy']); unset($serialized['createdBy']);
@ -73,11 +72,11 @@ final class KanbanCardCommentTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'description' => 'Description', 'description' => 'Description',
'descriptionRaw' => 'DescriptionRaw', 'descriptionRaw' => 'DescriptionRaw',
'card' => 2, 'card' => 2,
'media' => [], 'media' => [],
], ],
$serialized $serialized
); );

View File

@ -19,9 +19,7 @@ use Modules\Kanban\Models\CardStatus;
use Modules\Kanban\Models\CardType; use Modules\Kanban\Models\CardType;
use Modules\Kanban\Models\KanbanCard; use Modules\Kanban\Models\KanbanCard;
use Modules\Kanban\Models\KanbanCardMapper; use Modules\Kanban\Models\KanbanCardMapper;
use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag; use Modules\Tag\Models\Tag;
use phpOMS\Utils\RnG\Text;
/** /**
* @internal * @internal
@ -29,6 +27,7 @@ use phpOMS\Utils\RnG\Text;
final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @depends Modules\Kanban\tests\Models\KanbanCardMapperTest::testCRUD
* @covers Modules\Kanban\Models\KanbanCardMapper * @covers Modules\Kanban\Models\KanbanCardMapper
* @group module * @group module
*/ */
@ -40,8 +39,8 @@ final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
$card->description = 'This is some card description'; $card->description = 'This is some card description';
$card->setStatus(CardStatus::ACTIVE); $card->setStatus(CardStatus::ACTIVE);
$card->setType(CardType::TEXT); $card->setType(CardType::TEXT);
$card->order = 1; $card->order = 1;
$card->column = 1; $card->column = 1;
$card->createdBy = new NullAccount(1); $card->createdBy = new NullAccount(1);
$card->addTag(new Tag()); $card->addTag(new Tag());
$card->addTag(new Tag()); $card->addTag(new Tag());
@ -72,9 +71,9 @@ final class KanbanCardMapperTest extends \PHPUnit\Framework\TestCase
$card->setStatus(CardStatus::ACTIVE); $card->setStatus(CardStatus::ACTIVE);
$card->setType(CardType::TASK); $card->setType(CardType::TASK);
$card->ref = 1; $card->ref = 1;
$card->order = 1; $card->order = 1;
$card->column = 1; $card->column = 1;
$card->createdBy = new NullAccount(1); $card->createdBy = new NullAccount(1);
$card->addTag(new Tag()); $card->addTag(new Tag());
$card->addTag(new Tag()); $card->addTag(new Tag());

View File

@ -14,13 +14,12 @@ declare(strict_types=1);
namespace Modules\Kanban\tests\Models; namespace Modules\Kanban\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\Kanban\Models\CardStatus; use Modules\Kanban\Models\CardStatus;
use Modules\Kanban\Models\CardType; use Modules\Kanban\Models\CardType;
use Modules\Kanban\Models\KanbanCard; use Modules\Kanban\Models\KanbanCard;
use Modules\Media\Models\NullMedia; use Modules\Media\Models\NullMedia;
use Modules\Tasks\Models\Task;
use Modules\Tag\Models\Tag; use Modules\Tag\Models\Tag;
use Modules\Tasks\Models\Task;
/** /**
* @internal * @internal
@ -150,11 +149,11 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->card->name = 'Title'; $this->card->name = 'Title';
$this->card->description = 'Description'; $this->card->description = 'Description';
$this->card->descriptionRaw = 'DescriptionRaw'; $this->card->descriptionRaw = 'DescriptionRaw';
$this->card->order = 3; $this->card->order = 3;
$this->card->column = 2; $this->card->column = 2;
$this->card->setStatus(CardStatus::ARCHIVED); $this->card->setStatus(CardStatus::ARCHIVED);
$this->card->setType(CardType::TASK); $this->card->setType(CardType::TASK);
@ -164,17 +163,17 @@ final class KanbanCardTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'title' => 'Title', 'title' => 'Title',
'description' => 'Description', 'description' => 'Description',
'descriptionRaw' => 'DescriptionRaw', 'descriptionRaw' => 'DescriptionRaw',
'status' => CardStatus::ARCHIVED, 'status' => CardStatus::ARCHIVED,
'type' => CardType::TASK, 'type' => CardType::TASK,
'column' => 2, 'column' => 2,
'order' => 3, 'order' => 3,
'ref' => 0, 'ref' => 0,
'comments' => [], 'comments' => [],
'media' => [], 'media' => [],
], ],
$serialized $serialized
); );

View File

@ -16,7 +16,6 @@ namespace Modules\Kanban\tests\Models;
use Modules\Kanban\Models\KanbanColumn; use Modules\Kanban\Models\KanbanColumn;
use Modules\Kanban\Models\KanbanColumnMapper; use Modules\Kanban\Models\KanbanColumnMapper;
use phpOMS\Utils\RnG\Text;
/** /**
* @internal * @internal
@ -24,6 +23,7 @@ use phpOMS\Utils\RnG\Text;
final class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase final class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @depends Modules\Kanban\tests\Models\KanbanBoardMapperTest::testCRUD
* @covers Modules\Kanban\Models\KanbanColumnMapper * @covers Modules\Kanban\Models\KanbanColumnMapper
* @group module * @group module
*/ */
@ -31,7 +31,7 @@ final class KanbanColumnMapperTest extends \PHPUnit\Framework\TestCase
{ {
$column = new KanbanColumn(); $column = new KanbanColumn();
$column->name = 'Some Column'; $column->name = 'Some Column';
$column->board = 1; $column->board = 1;
$column->order = 1; $column->order = 1;

View File

@ -74,7 +74,7 @@ final class KanbanColumnTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->column->name = 'Name'; $this->column->name = 'Name';
$this->column->board = 2; $this->column->board = 2;
$this->column->order = 3; $this->column->order = 3;
@ -84,10 +84,10 @@ final class KanbanColumnTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[ [
'id' => 0, 'id' => 0,
'name' => 'Name', 'name' => 'Name',
'order' => 3, 'order' => 3,
'board' => 2, 'board' => 2,
'cards' => [], 'cards' => [],
], ],
$serialized $serialized