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
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.
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]`.
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.
### Code Style

View File

@ -89,9 +89,9 @@ final class ApiController extends Controller
$card->descriptionRaw = (string) ($request->getData('plain') ?? '');
$card->description = Markdown::parse((string) ($request->getData('plain') ?? ''));
$card->style = (string) ($request->getData('style') ?? '');
$card->column = (int) $request->getData('column');
$card->order = (int) ($request->getData('order') ?? 1);
$card->ref = (int) ($request->getData('ref') ?? 0);
$card->column = (int) $request->getData('column');
$card->order = (int) ($request->getData('order') ?? 1);
$card->ref = (int) ($request->getData('ref') ?? 0);
$card->setStatus((int) ($request->getData('status') ?? CardStatus::ACTIVE));
$card->setType((int) ($request->getData('type') ?? CardType::TEXT));
$card->createdBy = new NullAccount($request->header->account);
@ -207,8 +207,8 @@ final class ApiController extends Controller
$comment = new KanbanCardComment();
$comment->description = Markdown::parse((string) ($request->getData('plain') ?? ''));
$comment->descriptionRaw = (string) ($request->getData('plain') ?? '');
$comment->card = (int) $request->getData('card');
$comment->createdBy = new NullAccount($request->header->account);
$comment->card = (int) $request->getData('card');
$comment->createdBy = new NullAccount($request->header->account);
if (!empty($uploadedFiles = $request->getFiles() ?? [])) {
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
@ -421,8 +421,8 @@ final class ApiController extends Controller
*/
public function createKanbanColumnFromRequest(RequestAbstract $request) : KanbanColumn
{
$column = new KanbanColumn();
$column->name = (string) $request->getData('title');
$column = new KanbanColumn();
$column->name = (string) $request->getData('title');
$column->board = (int) $request->getData('board');
$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\NullAccount;
use Modules\Tag\Models\Tag;
use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
/**
* Kanban board class.
@ -258,10 +258,10 @@ class KanbanBoard implements \JsonSerializable
public function toArray() : array
{
return [
'id' => $this->id,
'status' => $this->status,
'id' => $this->id,
'status' => $this->status,
'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\NullAccount;
use Modules\Media\Models\Media;
use Modules\Tag\Models\Tag;
use Modules\Tag\Models\NullTag;
use Modules\Tag\Models\Tag;
use Modules\Tasks\Models\Task;
/**
@ -364,19 +364,19 @@ class KanbanCard implements \JsonSerializable
public function toArray() : array
{
return [
'id' => $this->id,
'title' => $this->name,
'description' => $this->description,
'id' => $this->id,
'title' => $this->name,
'description' => $this->description,
'descriptionRaw' => $this->descriptionRaw,
'status' => $this->status,
'type' => $this->type,
'column' => $this->column,
'order' => $this->order,
'ref' => $this->ref,
'createdBy' => $this->createdBy,
'createdAt' => $this->createdAt,
'comments' => $this->comments,
'media' => $this->media,
'status' => $this->status,
'type' => $this->type,
'column' => $this->column,
'order' => $this->order,
'ref' => $this->ref,
'createdBy' => $this->createdBy,
'createdAt' => $this->createdAt,
'comments' => $this->comments,
'media' => $this->media,
];
}

View File

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

View File

@ -128,11 +128,11 @@ class KanbanColumn implements \JsonSerializable
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'order' => $this->order,
'id' => $this->id,
'name' => $this->name,
'order' => $this->order,
'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\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
use phpOMS\Module\ModuleAbstract;
use phpOMS\System\MimeType;
use phpOMS\Message\Http\RequestStatusCode;
/**
* @internal

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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