mirror of
https://github.com/Karaka-Management/oms-ProjectManagement.git
synced 2026-01-29 15:48:40 +00:00
add unit tests
This commit is contained in:
parent
12d7a4a24d
commit
5c24838e95
|
|
@ -33,6 +33,7 @@ final class NullProject extends Project
|
|||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class Project
|
|||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private \DateTime $start;
|
||||
public \DateTime $start;
|
||||
|
||||
/**
|
||||
* End date.
|
||||
|
|
@ -54,7 +54,7 @@ class Project
|
|||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private \DateTime $end;
|
||||
public \DateTime $end;
|
||||
|
||||
/**
|
||||
* Estimated end date.
|
||||
|
|
@ -62,7 +62,7 @@ class Project
|
|||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private \DateTime $endEstimated;
|
||||
public \DateTime $endEstimated;
|
||||
|
||||
/**
|
||||
* Project name.
|
||||
|
|
@ -102,7 +102,7 @@ class Project
|
|||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Money $costs;
|
||||
public Money $costs;
|
||||
|
||||
/**
|
||||
* Budget costs.
|
||||
|
|
@ -110,7 +110,7 @@ class Project
|
|||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Money $budgetCosts;
|
||||
public Money $budgetCosts;
|
||||
|
||||
/**
|
||||
* Budget earnings.
|
||||
|
|
@ -118,7 +118,7 @@ class Project
|
|||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Money $budgetEarnings;
|
||||
public Money $budgetEarnings;
|
||||
|
||||
/**
|
||||
* Current total earnings.
|
||||
|
|
@ -126,7 +126,7 @@ class Project
|
|||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private Money $earnings;
|
||||
public Money $earnings;
|
||||
|
||||
/**
|
||||
* Progress percentage.
|
||||
|
|
@ -134,7 +134,7 @@ class Project
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $progress = 0;
|
||||
public int $progress = 0;
|
||||
|
||||
/**
|
||||
* Progress calculation.
|
||||
|
|
@ -222,7 +222,7 @@ class Project
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMedias() : array
|
||||
public function getMedia() : array
|
||||
{
|
||||
return $this->media;
|
||||
}
|
||||
|
|
@ -238,11 +238,7 @@ class Project
|
|||
*/
|
||||
public function addMedia($media) : void
|
||||
{
|
||||
if ($media instanceof Media && $media->getId() !== 0) {
|
||||
$this->media[$media->getId()] = $media;
|
||||
} else {
|
||||
$this->media[] = $media;
|
||||
}
|
||||
$this->media[] = $media;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -276,11 +272,7 @@ class Project
|
|||
*/
|
||||
public function addTask(Task $task) : void
|
||||
{
|
||||
if ($task->getId() !== 0) {
|
||||
$this->tasks[$task->getId()] = $task;
|
||||
} else {
|
||||
$this->tasks[] = $task;
|
||||
}
|
||||
$this->tasks[] = $task;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -303,32 +295,6 @@ class Project
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get progress
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getProgress() : int
|
||||
{
|
||||
return $this->progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set progress
|
||||
*
|
||||
* @param int $progress Progress
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setProgress(int $progress) : void
|
||||
{
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get progress type
|
||||
*
|
||||
|
|
@ -369,20 +335,6 @@ class Project
|
|||
return $this->tasks[$id] ?? new Task();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media
|
||||
*
|
||||
* @param int $id Media id
|
||||
*
|
||||
* @return int|Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMedia(int $id)
|
||||
{
|
||||
return $this->media[$id] ?? new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tasks
|
||||
*
|
||||
|
|
@ -395,108 +347,6 @@ class Project
|
|||
return $this->tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count tasks
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function countTasks() : int
|
||||
{
|
||||
return \count($this->tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count media
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function countMedia() : int
|
||||
{
|
||||
return \count($this->media);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get start date
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getStart() : \DateTime
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set start date
|
||||
*
|
||||
* @param \DateTime $start Start date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStart(\DateTime $start) : void
|
||||
{
|
||||
$this->start = $start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set end date
|
||||
*
|
||||
* @param \DateTime $end End date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setEnd(\DateTime $end) : void
|
||||
{
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get end date
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getEnd() : \DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set estimated end date
|
||||
*
|
||||
* @param \DateTime $end End date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setEstimatedEnd(\DateTime $end) : void
|
||||
{
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get estimated end date
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getEstimatedEnd() : \DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
|
|
@ -525,106 +375,34 @@ class Project
|
|||
}
|
||||
|
||||
/**
|
||||
* Get costs
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCosts() : Money
|
||||
public function toArray() : array
|
||||
{
|
||||
return $this->costs;
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'start' => $this->start,
|
||||
'end' => $this->end,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'calendar' => $this->calendar,
|
||||
'costs' => $this->costs,
|
||||
'budgetCosts' => $this->budgetCosts,
|
||||
'budgetEarnings' => $this->budgetEarnings,
|
||||
'earnings' => $this->earnings,
|
||||
'tasks' => $this->tasks,
|
||||
'media' => $this->media,
|
||||
'progress' => $this->progress,
|
||||
'progressType' => $this->progressType,
|
||||
'createdAt' => $this->createdAt,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get budget costs
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBudgetCosts() : Money
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->budgetCosts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get budget earnings
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
*/
|
||||
public function getBudgetEarnings() : Money
|
||||
{
|
||||
return $this->budgetEarnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get earnings
|
||||
*
|
||||
* @return Money
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
*/
|
||||
public function getEarnings() : Money
|
||||
{
|
||||
return $this->earnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set costs
|
||||
*
|
||||
* @param Money $costs Costs
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCosts(Money $costs) : void
|
||||
{
|
||||
$this->costs = $costs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set budget costs
|
||||
*
|
||||
* @param Money $budget Budget
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setBudgetCosts(Money $budget) : void
|
||||
{
|
||||
$this->budgetCosts = $budget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set budget earnings
|
||||
*
|
||||
* @param Money $budget Budget
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setBudgetEarnings(Money $budget) : void
|
||||
{
|
||||
$this->budgetEarnings = $budget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set earnings
|
||||
*
|
||||
* @param Money $earnings Earnings
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setEarnings(Money $earnings) : void
|
||||
{
|
||||
$this->earnings = $earnings;
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
tests/Models/NullProjectTest.php
Normal file
42
tests/Models/NullProjectTest.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @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\ProjectManagement\tests\Models;
|
||||
|
||||
use Modules\ProjectManagement\Models\NullProject;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullProjectTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\NullProject
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\ProjectManagement\Models\Project', new NullProject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\NullProject
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullProject(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -39,16 +39,16 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$project->setName('Projectname');
|
||||
$project->description = 'Description';
|
||||
$project->createdBy = new NullAccount(1);
|
||||
$project->setStart(new \DateTime('2000-05-05'));
|
||||
$project->setEnd(new \DateTime('2005-05-05'));
|
||||
$project->start = new \DateTime('2000-05-05');
|
||||
$project->end = new \DateTime('2005-05-05');
|
||||
|
||||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$project->setCosts($money);
|
||||
$project->setBudgetCosts($money);
|
||||
$project->setBudgetEarnings($money);
|
||||
$project->setEarnings($money);
|
||||
$project->costs = $money;
|
||||
$project->budgetCosts = $money;
|
||||
$project->budgetEarnings = $money;
|
||||
$project->earnings = $money;
|
||||
|
||||
$task = new Task();
|
||||
$task->title = 'ProjectTask 1';
|
||||
|
|
@ -61,7 +61,7 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$project->addTask($task);
|
||||
$project->addTask($task2);
|
||||
|
||||
$project->setProgress(10);
|
||||
$project->progress = 10;
|
||||
$project->setProgressType(ProgressType::TASKS);
|
||||
|
||||
$media = new Media();
|
||||
|
|
@ -81,19 +81,18 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals($project->getName(), $projectR->getName());
|
||||
self::assertEquals($project->description, $projectR->description);
|
||||
self::assertEquals($project->countTasks(), $projectR->countTasks());
|
||||
self::assertEquals($project->getCosts()->getAmount(), $projectR->getCosts()->getAmount());
|
||||
self::assertEquals($project->getBudgetEarnings()->getAmount(), $projectR->getBudgetEarnings()->getAmount());
|
||||
self::assertEquals($project->getBudgetCosts()->getAmount(), $projectR->getBudgetCosts()->getAmount());
|
||||
self::assertEquals($project->getEarnings()->getAmount(), $projectR->getEarnings()->getAmount());
|
||||
self::assertEquals($project->costs->getAmount(), $projectR->costs->getAmount());
|
||||
self::assertEquals($project->budgetEarnings->getAmount(), $projectR->budgetEarnings->getAmount());
|
||||
self::assertEquals($project->budgetCosts->getAmount(), $projectR->budgetCosts->getAmount());
|
||||
self::assertEquals($project->earnings->getAmount(), $projectR->earnings->getAmount());
|
||||
self::assertEquals($project->createdAt->format('Y-m-d'), $projectR->createdAt->format('Y-m-d'));
|
||||
self::assertEquals($project->getStart()->format('Y-m-d'), $projectR->getStart()->format('Y-m-d'));
|
||||
self::assertEquals($project->getEnd()->format('Y-m-d'), $projectR->getEnd()->format('Y-m-d'));
|
||||
self::assertEquals($project->getProgress(), $projectR->getProgress());
|
||||
self::assertEquals($project->start->format('Y-m-d'), $projectR->start->format('Y-m-d'));
|
||||
self::assertEquals($project->end->format('Y-m-d'), $projectR->end->format('Y-m-d'));
|
||||
self::assertEquals($project->progress, $projectR->progress);
|
||||
self::assertEquals($project->getProgressType(), $projectR->getProgressType());
|
||||
|
||||
$expected = $project->getMedias();
|
||||
$actual = $projectR->getMedias();
|
||||
$expected = $project->getMedia();
|
||||
$actual = $projectR->getMedia();
|
||||
|
||||
self::assertEquals(\end($expected)->name, \end($actual)->name);
|
||||
}
|
||||
|
|
@ -108,36 +107,4 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertCount(1, $newest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group volume
|
||||
* @group module
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testVolume() : void
|
||||
{
|
||||
for ($i = 1; $i < 100; ++$i) {
|
||||
$text = new Text();
|
||||
|
||||
$project = new Project();
|
||||
|
||||
$project->setName($text->generateText(\mt_rand(3, 7)));
|
||||
$project->description = $text->generateText(\mt_rand(20, 100));
|
||||
$project->createdBy = new NullAccount(1);
|
||||
$project->setStart(new \DateTime('2000-05-05'));
|
||||
$project->setEnd(new \DateTime('2005-05-05'));
|
||||
$project->setProgress(\mt_rand(0, 100));
|
||||
$project->setProgressType(\mt_rand(0, 4));
|
||||
|
||||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$project->setCosts($money);
|
||||
$project->setBudgetCosts($money);
|
||||
$project->setBudgetEarnings($money);
|
||||
$project->setEarnings($money);
|
||||
|
||||
$id = ProjectMapper::create($project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace Modules\ProjectManagement\tests\Models;
|
|||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\ProjectManagement\Models\ProgressType;
|
||||
use Modules\ProjectManagement\Models\Project;
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Tasks\Models\Task;
|
||||
use phpOMS\Localization\Money;
|
||||
|
||||
|
|
@ -25,83 +26,169 @@ use phpOMS\Localization\Money;
|
|||
*/
|
||||
final class ProjectTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private Project $project;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->project = new Project();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
$project = new Project();
|
||||
self::assertEquals(0, $this->project->getId());
|
||||
self::assertInstanceOf('\Modules\Calendar\Models\Calendar', $this->project->calendar);
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->project->createdAt->format('Y-m-d'));
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->project->start->format('Y-m-d'));
|
||||
self::assertEquals((new \DateTime('now'))->modify('+1 month')->format('Y-m-d'), $this->project->end->format('Y-m-d'));
|
||||
self::assertEquals(0, $this->project->createdBy->getId());
|
||||
self::assertEquals('', $this->project->getName());
|
||||
self::assertEquals('', $this->project->description);
|
||||
self::assertEquals(0, $this->project->costs->getInt());
|
||||
self::assertEquals(0, $this->project->budgetCosts->getInt());
|
||||
self::assertEquals(0, $this->project->budgetEarnings->getInt());
|
||||
self::assertEquals(0, $this->project->earnings->getInt());
|
||||
self::assertEquals(0, $this->project->progress);
|
||||
self::assertEquals([], $this->project->getMedia());
|
||||
self::assertEquals(ProgressType::MANUAL, $this->project->getProgressType());
|
||||
self::assertEmpty($this->project->getTasks());
|
||||
self::assertFalse($this->project->removeTask(2));
|
||||
self::assertInstanceOf('\Modules\Tasks\Models\Task', $this->project->getTask(0));
|
||||
}
|
||||
|
||||
self::assertEquals(0, $project->getId());
|
||||
self::assertInstanceOf('\Modules\Calendar\Models\Calendar', $project->calendar);
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $project->createdAt->format('Y-m-d'));
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $project->getStart()->format('Y-m-d'));
|
||||
self::assertEquals((new \DateTime('now'))->modify('+1 month')->format('Y-m-d'), $project->getEnd()->format('Y-m-d'));
|
||||
self::assertEquals(0, $project->createdBy->getId());
|
||||
self::assertEquals('', $project->getName());
|
||||
self::assertEquals('', $project->description);
|
||||
self::assertEquals(0, $project->getCosts()->getInt());
|
||||
self::assertEquals(0, $project->getBudgetCosts()->getInt());
|
||||
self::assertEquals(0, $project->getBudgetEarnings()->getInt());
|
||||
self::assertEquals(0, $project->getEarnings()->getInt());
|
||||
self::assertEquals(0, $project->getProgress());
|
||||
self::assertEquals(ProgressType::MANUAL, $project->getProgressType());
|
||||
self::assertEmpty($project->getTasks());
|
||||
self::assertFalse($project->removeTask(2));
|
||||
self::assertInstanceOf('\Modules\Tasks\Models\Task', $project->getTask(0));
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testCreatedByInputOutput() : void
|
||||
{
|
||||
$this->project->createdBy = new NullAccount(1);
|
||||
self::assertEquals(1, $this->project->createdBy->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testSetGet() : void
|
||||
public function testNameInputOutput() : void
|
||||
{
|
||||
$project = new Project();
|
||||
$this->project->setName('Name');
|
||||
self::assertEquals('Name', $this->project->getName());
|
||||
}
|
||||
|
||||
$project->setName('Project');
|
||||
self::assertEquals('Project', $project->getName());
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testDescriptionInputOutput() : void
|
||||
{
|
||||
$this->project->description = 'Description';
|
||||
self::assertEquals('Description', $this->project->description);
|
||||
}
|
||||
|
||||
$project->description = 'Description';
|
||||
self::assertEquals('Description', $project->description);
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testProgressInputOutput() : void
|
||||
{
|
||||
$this->project->progress = 10;
|
||||
self::assertEquals(10, $this->project->progress);
|
||||
}
|
||||
|
||||
$project->setStart($date = new \DateTime('2000-05-05'));
|
||||
self::assertEquals($date->format('Y-m-d'), $project->getStart()->format('Y-m-d'));
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testProgressTypeInputOutput() : void
|
||||
{
|
||||
$this->project->setProgressType(ProgressType::TASKS);
|
||||
self::assertEquals(ProgressType::TASKS, $this->project->getProgressType());
|
||||
}
|
||||
|
||||
$project->setEnd($date = new \DateTime('2000-05-05'));
|
||||
self::assertEquals($date->format('Y-m-d'), $project->getEnd()->format('Y-m-d'));
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testMediaInputOutput() : void
|
||||
{
|
||||
$this->project->addMedia(new Media());
|
||||
self::assertCount(1, $this->project->getMedia());
|
||||
}
|
||||
|
||||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testMediaRemove() : void
|
||||
{
|
||||
$media = new Media();
|
||||
|
||||
$project->setCosts($money);
|
||||
self::assertEquals($money->getAmount(), $project->getCosts()->getAmount());
|
||||
|
||||
$project->setBudgetCosts($money);
|
||||
self::assertEquals($money->getAmount(), $project->getBudgetCosts()->getAmount());
|
||||
|
||||
$project->setBudgetEarnings($money);
|
||||
self::assertEquals($money->getAmount(), $project->getBudgetEarnings()->getAmount());
|
||||
|
||||
$project->setEarnings($money);
|
||||
self::assertEquals($money->getAmount(), $project->getEarnings()->getAmount());
|
||||
$this->project->addMedia($media);
|
||||
self::assertTrue($this->project->removeMedia(0));
|
||||
self::assertCount(0, $this->project->getMedia());
|
||||
self::assertFalse($this->project->removeMedia(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testTaskInputOutput() : void
|
||||
{
|
||||
$task = new Task();
|
||||
$task->title = 'A';
|
||||
$task->setCreatedBy(new NullAccount(1));
|
||||
|
||||
$project->addTask($task);
|
||||
$this->project->addTask($task);
|
||||
self::assertEquals('A', $this->project->getTask(0)->title);
|
||||
|
||||
self::assertEquals('A', $project->getTask(0)->title);
|
||||
self::assertCount(1, $project->getTasks());
|
||||
self::assertTrue($project->removeTask(0));
|
||||
self::assertEquals(0, $project->countTasks());
|
||||
self::assertTrue($this->project->removeTask(0));
|
||||
self::assertCount(0, $this->project->getTasks());
|
||||
|
||||
$project->setProgress(10);
|
||||
self::assertEquals(10, $project->getProgress());
|
||||
$this->project->addTask($task);
|
||||
self::assertCount(1, $this->project->getTasks());
|
||||
}
|
||||
|
||||
$project->setProgressType(ProgressType::TASKS);
|
||||
self::assertEquals(ProgressType::TASKS, $project->getProgressType());
|
||||
/**
|
||||
* @covers Modules\ProjectManagement\Models\Project
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->project->setName('Name');
|
||||
$this->project->description = 'Description';
|
||||
$this->project->start = new \DateTime();
|
||||
$this->project->end = new \DateTime();
|
||||
$this->project->progress = 10;
|
||||
$this->project->setProgressType(ProgressType::TASKS);
|
||||
|
||||
$serialized = $this->project->jsonSerialize();
|
||||
unset($serialized['calendar']);
|
||||
unset($serialized['createdAt']);
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'start' => $this->project->start,
|
||||
'end' => $this->project->end,
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'costs' => new Money(),
|
||||
'budgetCosts' => new Money(),
|
||||
'budgetEarnings' => new Money(),
|
||||
'earnings' => new Money(),
|
||||
'tasks' => [],
|
||||
'media' => [],
|
||||
'progress' => 10,
|
||||
'progressType' => ProgressType::TASKS,
|
||||
],
|
||||
$serialized
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
|
||||
<exclude>
|
||||
<directory>*vendor*</directory>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user