diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cab9f5e..ad8944e 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/Models/Cause.php b/Models/Cause.php index ddbb173..96b9a53 100755 --- a/Models/Cause.php +++ b/Models/Cause.php @@ -50,13 +50,13 @@ class Cause */ public string $descriptionRaw = ''; - private int $probability = 0; + public int $probability = 0; - private ?Department $department = null; + public ?Department $department = null; - private ?Risk $risk = null; + public ?Risk $risk = null; - private ?Category $category = null; + public ?Category $category = null; /** * Get id. @@ -69,108 +69,4 @@ class Cause { return $this->id; } - - /** - * Set risk. - * - * @param mixed $risk Risk - * - * @return void - * - * @since 1.0.0 - */ - public function setRisk($risk) : void - { - $this->risk = $risk; - } - - /** - * Get risk. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getRisk() - { - return $this->risk; - } - - /** - * Get category. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getCategory() - { - return $this->category; - } - - /** - * Set category. - * - * @param mixed $category Category - * - * @return void - * - * @since 1.0.0 - */ - public function setCategory($category) : void - { - $this->category = $category; - } - - /** - * Get probability. - * - * @return int - * - * @since 1.0.0 - */ - public function getProbability() : int - { - return $this->probability; - } - - /** - * Set probability. - * - * @param int $probability Probability - * - * @return void - * - * @since 1.0.0 - */ - public function setProbability(int $probability) : void - { - $this->probability = $probability; - } - - /** - * Get department. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDepartment() - { - return $this->department; - } - - /** - * Set department. - * - * @param mixed $department Department - * - * @return void - * - * @since 1.0.0 - */ - public function setDepartment($department) : void - { - $this->department = $department; - } } diff --git a/Models/Department.php b/Models/Department.php index 111505c..0870130 100755 --- a/Models/Department.php +++ b/Models/Department.php @@ -36,9 +36,9 @@ class Department public ?OrgDepartment $department = null; - private ?int $responsible = null; + public ?int $responsible = null; - private ?int $deputy = null; + public ?int $deputy = null; /** * Get id. @@ -51,56 +51,4 @@ class Department { return $this->id; } - - /** - * Get responsible. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getResponsible() - { - return $this->responsible; - } - - /** - * set responsible. - * - * @param mixed $responsible Responsible - * - * @return void - * - * @since 1.0.0 - */ - public function setResponsible($responsible) : void - { - $this->responsible = $responsible; - } - - /** - * Get deputy. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDeputy() - { - return $this->deputy; - } - - /** - * Set deputy. - * - * @param mixed $deputy Deputy - * - * @return void - * - * @since 1.0.0 - */ - public function setDeputy($deputy) : void - { - $this->deputy = $deputy; - } } diff --git a/Models/Process.php b/Models/Process.php index 4483921..be0d9fb 100755 --- a/Models/Process.php +++ b/Models/Process.php @@ -52,13 +52,13 @@ class Process */ public string $descriptionRaw = ''; - private ?Department $department = null; + public ?Department $department = null; - private ?int $responsible = null; + public ?int $responsible = null; - private ?int $deputy = null; + public ?int $deputy = null; - private ?Unit $unit = null; + public ?Unit $unit = null; /** * Get id. @@ -71,108 +71,4 @@ class Process { return $this->id; } - - /** - * Get unit. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getUnit() - { - return $this->unit; - } - - /** - * Set unit. - * - * @param mixed $unit Unit - * - * @return void - * - * @since 1.0.0 - */ - public function setUnit($unit) : void - { - $this->unit = $unit; - } - - /** - * Get department. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDepartment() - { - return $this->department; - } - - /** - * Set department. - * - * @param mixed $department Department - * - * @return void - * - * @since 1.0.0 - */ - public function setDepartment($department) : void - { - $this->department = $department; - } - - /** - * Get responsible. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getResponsible() - { - return $this->responsible; - } - - /** - * Set responsible. - * - * @param mixed $responsible Responsible - * - * @return void - * - * @since 1.0.0 - */ - public function setResponsible($responsible) : void - { - $this->responsible = $responsible; - } - - /** - * Get deputy. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDeputy() - { - return $this->deputy; - } - - /** - * Set deputy. - * - * @param mixed $deputy Deputy - * - * @return void - * - * @since 1.0.0 - */ - public function setDeputy($deputy) : void - { - $this->deputy = $deputy; - } } diff --git a/Models/Project.php b/Models/Project.php index 06c4e18..b25270b 100755 --- a/Models/Project.php +++ b/Models/Project.php @@ -34,11 +34,11 @@ class Project */ protected int $id = 0; - private ?PMProject $project = null; + public ?PMProject $project = null; - private ?int $responsible = null; + public ?int $responsible = null; - private ?int $deputy = null; + public ?int $deputy = null; /** * Get id. @@ -51,82 +51,4 @@ class Project { return $this->id; } - - /** - * Get project. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getProject() - { - return $this->project; - } - - /** - * Set project. - * - * @param mixed $project Project - * - * @return void - * - * @since 1.0.0 - */ - public function setProject($project) : void - { - $this->project = $project; - } - - /** - * Get responsible. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getResponsible() - { - return $this->responsible; - } - - /** - * Set responsible. - * - * @param mixed $responsible Responsible - * - * @return void - * - * @since 1.0.0 - */ - public function setResponsible($responsible) : void - { - $this->responsible = $responsible; - } - - /** - * Get deputy. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDeputy() - { - return $this->deputy; - } - - /** - * Set deputy. - * - * @param mixed $deputy Deputy - * - * @return void - * - * @since 1.0.0 - */ - public function setDeputy($deputy) : void - { - $this->deputy = $deputy; - } } diff --git a/Models/Risk.php b/Models/Risk.php index 42a04f6..b42782b 100755 --- a/Models/Risk.php +++ b/Models/Risk.php @@ -59,19 +59,19 @@ class Risk */ public string $descriptionRaw = ''; - private ?Unit $unit = null; + public ?Unit $unit = null; - private ?Department $department = null; + public ?Department $department = null; - private ?Category $category = null; + public ?Category $category = null; - private ?Project $project = null; + public ?Project $project = null; - private ?Process $process = null; + public ?Process $process = null; - private ?int $responsible = null; + public ?int $responsible = null; - private ?int $deputy = null; + public ?int $deputy = null; private array $histScore = []; @@ -83,7 +83,7 @@ class Risk private array $media = []; - private \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; /** * Constructor. @@ -236,186 +236,4 @@ class Risk { return $this->histScore; } - - /** - * Get unit. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getUnit() - { - return $this->unit; - } - - /** - * Set unit. - * - * @param mixed $unit Unit - * - * @return void - * - * @since 1.0.0 - */ - public function setUnit($unit) : void - { - $this->unit = $unit; - } - - /** - * Get department. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDepartment() - { - return $this->department; - } - - /** - * Set department. - * - * @param mixed $department Department - * - * @return void - * - * @since 1.0.0 - */ - public function setDepartment($department) : void - { - $this->department = $department; - } - - /** - * Get category. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getCategory() - { - return $this->category; - } - - /** - * Set category. - * - * @param mixed $category Category - * - * @return void - * - * @since 1.0.0 - */ - public function setCategory($category) : void - { - $this->category = $category; - } - - /** - * Get project. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getProject() - { - return $this->project; - } - - /** - * Set project. - * - * @param mixed $project Project - * - * @return void - * - * @since 1.0.0 - */ - public function setProject($project) : void - { - $this->project = $project; - } - - /** - * Get process. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getProcess() - { - return $this->process; - } - - /** - * Set process. - * - * @param mixed $process Process - * - * @return void - * - * @since 1.0.0 - */ - public function setProcess($process) : void - { - $this->process = $process; - } - - /** - * Get responsible. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getResponsible() - { - return $this->responsible; - } - - /** - * Set responsible. - * - * @param mixed $responsible Responsible - * - * @return void - * - * @since 1.0.0 - */ - public function setResponsible($responsible) : void - { - $this->responsible = $responsible; - } - - /** - * Get deputy. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getDeputy() - { - return $this->deputy; - } - - /** - * Set deputy. - * - * @param mixed $deputy Deputy - * - * @return void - * - * @since 1.0.0 - */ - public function setDeputy($deputy) : void - { - $this->deputy = $deputy; - } } diff --git a/Models/RiskObject.php b/Models/RiskObject.php index b937f7c..25c9215 100755 --- a/Models/RiskObject.php +++ b/Models/RiskObject.php @@ -50,7 +50,7 @@ class RiskObject */ public string $descriptionRaw = ''; - private ?int $risk = null; + public ?int $risk = null; /** * Get id. @@ -63,30 +63,4 @@ class RiskObject { return $this->id; } - - /** - * Get risk. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getRisk() - { - return $this->risk; - } - - /** - * Set risk. - * - * @param mixed $risk Risk - * - * @return void - * - * @since 1.0.0 - */ - public function setRisk($risk) : void - { - $this->risk = $risk; - } } diff --git a/Models/Solution.php b/Models/Solution.php index e507746..f6fcaa8 100755 --- a/Models/Solution.php +++ b/Models/Solution.php @@ -50,11 +50,11 @@ class Solution */ public string $descriptionRaw = ''; - private int $probability = 0; + public int $probability = 0; - private ?Cause $cause = null; + public ?Cause $cause = null; - private ?Risk $risk = null; + public ?Risk $risk = null; /** * Get id. @@ -67,120 +67,4 @@ class Solution { return $this->id; } - - /** - * Set risk. - * - * @param mixed $risk Risk - * - * @return void - * - * @since 1.0.0 - */ - public function setRisk($risk) : void - { - $this->risk = $risk; - } - - /** - * Get risk. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getRisk() - { - return $this->risk; - } - - /** - * Set cause. - * - * @param mixed $cause Cause - * - * @return void - * - * @since 1.0.0 - */ - public function setCause($cause) : void - { - $this->cause = $cause; - } - - /** - * Get cause. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getCause() - { - return $this->cause; - } - - /** - * Get probability. - * - * @return int - * - * @since 1.0.0 - */ - public function getProbability() : int - { - return $this->probability; - } - - /** - * Set probability. - * - * @param int $probability Probability - * - * @return void - * - * @since 1.0.0 - */ - public function setProbability(int $probability) : void - { - $this->probability = $probability; - } - - /** - * Get description - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Get raw description. - * - * @return string - * - * @since 1.0.0 - */ - public function getDescriptionRaw() : string - { - return $this->descriptionRaw; - } - - /** - * Set raw description. - * - * @param string $description Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescriptionRaw(string $description) : void - { - $this->descriptionRaw = $description; - } } diff --git a/tests/Models/CategoryTest.php b/tests/Models/CategoryTest.php index 0a317df..2c45791 100755 --- a/tests/Models/CategoryTest.php +++ b/tests/Models/CategoryTest.php @@ -37,28 +37,4 @@ final class CategoryTest extends \PHPUnit\Framework\TestCase self::assertNull($obj->responsible); self::assertNull($obj->deputy); } - - /** - * @covers Modules\RiskManagement\Models\Category - * @group module - */ - public function testSetGet() : void - { - $obj = new Category(); - - $obj->title = 'Name'; - self::assertEquals('Name', $obj->title); - - $obj->descriptionRaw = 'Description'; - self::assertEquals('Description', $obj->descriptionRaw); - - $obj->responsible = 1; - self::assertEquals(1, $obj->responsible); - - $obj->deputy = 1; - self::assertEquals(1, $obj->deputy); - - $obj->parent = 1; - self::assertEquals(1, $obj->parent); - } } diff --git a/tests/Models/CauseMapperTest.php b/tests/Models/CauseMapperTest.php index 88cd91e..cba84ce 100755 --- a/tests/Models/CauseMapperTest.php +++ b/tests/Models/CauseMapperTest.php @@ -36,20 +36,20 @@ final class CauseMapperTest extends \PHPUnit\Framework\TestCase $obj = new Cause(); $obj->title = 'Cause Test'; $obj->descriptionRaw = 'Description'; - $obj->setProbability(1); + $obj->probability = 1; $department = new Department(); $department->department = new NullOrgDepartment(1); - $obj->setDepartment($department); + $obj->department = $department; $category = new Category(); $category->title = 'Test Cat'; - $obj->setCategory($category); + $obj->category = $category; $risk = new Risk(); $risk->name = 'Cause Test Risk'; - $risk->setUnit(new NullUnit(1)); - $obj->setRisk($risk); + $risk->unit = new NullUnit(1); + $obj->risk = $risk; CauseMapper::create($obj); @@ -58,7 +58,7 @@ final class CauseMapperTest extends \PHPUnit\Framework\TestCase self::assertEquals($obj->title, $objR->title); self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw); //self::assertEquals($obj->getDepartment()->department->getId(), $objR->getDepartment()->department->getId()); - self::assertEquals($obj->getCategory()->title, $objR->getCategory()->title); - self::assertEquals($obj->getRisk()->name, $objR->getRisk()->name); + self::assertEquals($obj->category->title, $objR->category->title); + self::assertEquals($obj->risk->name, $objR->risk->name); } } diff --git a/tests/Models/CauseTest.php b/tests/Models/CauseTest.php index 13f6d41..6f6c16e 100755 --- a/tests/Models/CauseTest.php +++ b/tests/Models/CauseTest.php @@ -15,9 +15,6 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; use Modules\RiskManagement\Models\Cause; -use Modules\RiskManagement\Models\NullCategory; -use Modules\RiskManagement\Models\NullDepartment; -use Modules\RiskManagement\Models\NullRisk; /** * @internal @@ -36,36 +33,9 @@ final class CauseTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $obj->title); self::assertEquals('', $obj->description); self::assertEquals('', $obj->descriptionRaw); - self::assertEquals(0, $obj->getProbability()); - self::assertNull($obj->getDepartment()); - self::assertNull($obj->getRisk()); - self::assertNull($obj->getCategory()); - } - - /** - * @covers Modules\RiskManagement\Models\Cause - * @group module - */ - public function testSetGet() : void - { - $obj = new Cause(); - - $obj->title = 'Name'; - self::assertEquals('Name', $obj->title); - - $obj->descriptionRaw = 'Description'; - self::assertEquals('Description', $obj->descriptionRaw); - - $obj->setProbability(1); - self::assertEquals(1, $obj->getProbability()); - - $obj->setCategory(new NullCategory(2)); - self::assertEquals(2, $obj->getCategory()->getId()); - - $obj->setRisk(new NullRisk(1)); - self::assertEquals(1, $obj->getRisk()->getId()); - - $obj->setDepartment(new NullDepartment(1)); - self::assertEquals(1, $obj->getDepartment()->getId()); + self::assertEquals(0, $obj->probability); + self::assertNull($obj->department); + self::assertNull($obj->risk); + self::assertNull($obj->category); } } diff --git a/tests/Models/DepartmentMapperTest.php b/tests/Models/DepartmentMapperTest.php index eab4d0f..a099e60 100755 --- a/tests/Models/DepartmentMapperTest.php +++ b/tests/Models/DepartmentMapperTest.php @@ -29,16 +29,16 @@ final class DepartmentMapperTest extends \PHPUnit\Framework\TestCase */ public function testCRUD() : void { - $obj = new Department(); - $obj->department = new NullDepartment(); - $obj->setResponsible(1); - $obj->setDeputy(1); + $obj = new Department(); + $obj->department = new NullDepartment(); + $obj->responsible = 1; + $obj->deputy = 1; DepartmentMapper::create($obj); $objR = DepartmentMapper::get($obj->getId()); self::assertEquals($obj->department->getId(), $objR->department->getId()); - self::assertEquals($obj->getResponsible(), $objR->getResponsible()); - self::assertEquals($obj->getDeputy(), $objR->getDeputy()); + self::assertEquals($obj->responsible, $objR->responsible); + self::assertEquals($obj->deputy, $objR->deputy); } } diff --git a/tests/Models/DepartmentTest.php b/tests/Models/DepartmentTest.php index 8a7fe16..2e1e825 100755 --- a/tests/Models/DepartmentTest.php +++ b/tests/Models/DepartmentTest.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; -use Modules\Organization\Models\NullDepartment as NullOrgDepartment; use Modules\RiskManagement\Models\Department; /** @@ -32,25 +31,7 @@ final class DepartmentTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $obj->getId()); self::assertNull($obj->department); - self::assertNull($obj->getResponsible()); - self::assertNull($obj->getDeputy()); - } - - /** - * @covers Modules\RiskManagement\Models\Department - * @group module - */ - public function testSetGet() : void - { - $obj = new Department(); - - $obj->department = new NullOrgDepartment(1); - self::assertEquals(1, $obj->department->getId()); - - $obj->setResponsible(1); - self::assertEquals(1, $obj->getResponsible()); - - $obj->setDeputy(3); - self::assertEquals(3, $obj->getDeputy()); + self::assertNull($obj->responsible); + self::assertNull($obj->deputy); } } diff --git a/tests/Models/NullCategoryTest.php b/tests/Models/NullCategoryTest.php new file mode 100644 index 0000000..c3ee5b0 --- /dev/null +++ b/tests/Models/NullCategoryTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullCauseTest.php b/tests/Models/NullCauseTest.php new file mode 100644 index 0000000..c70a1e6 --- /dev/null +++ b/tests/Models/NullCauseTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullDepartmentTest.php b/tests/Models/NullDepartmentTest.php new file mode 100644 index 0000000..b8dc620 --- /dev/null +++ b/tests/Models/NullDepartmentTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullProcessTest.php b/tests/Models/NullProcessTest.php new file mode 100644 index 0000000..80152c0 --- /dev/null +++ b/tests/Models/NullProcessTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullProjectTest.php b/tests/Models/NullProjectTest.php new file mode 100644 index 0000000..6cd3874 --- /dev/null +++ b/tests/Models/NullProjectTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullRiskObjectTest.php b/tests/Models/NullRiskObjectTest.php new file mode 100644 index 0000000..8c0f1f9 --- /dev/null +++ b/tests/Models/NullRiskObjectTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullRiskTest.php b/tests/Models/NullRiskTest.php new file mode 100644 index 0000000..b75773a --- /dev/null +++ b/tests/Models/NullRiskTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullSolutionTest.php b/tests/Models/NullSolutionTest.php new file mode 100644 index 0000000..d0e5799 --- /dev/null +++ b/tests/Models/NullSolutionTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/ProcessMapperTest.php b/tests/Models/ProcessMapperTest.php index 94c67cf..88ae1bb 100755 --- a/tests/Models/ProcessMapperTest.php +++ b/tests/Models/ProcessMapperTest.php @@ -33,19 +33,19 @@ final class ProcessMapperTest extends \PHPUnit\Framework\TestCase $obj = new Process(); $obj->title = 'Name'; $obj->descriptionRaw = 'Description'; - $obj->setDepartment(new NullDepartment(1)); - $obj->setResponsible(1); - $obj->setDeputy(1); - $obj->setUnit(new NullUnit(1)); + $obj->department = new NullDepartment(1); + $obj->responsible = 1; + $obj->deputy = 1; + $obj->unit = new NullUnit(1); ProcessMapper::create($obj); $objR = ProcessMapper::get($obj->getId()); self::assertEquals($obj->title, $objR->title); self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw); - self::assertEquals($obj->getResponsible(), $objR->getResponsible()); - self::assertEquals($obj->getDeputy(), $objR->getDeputy()); - self::assertEquals($obj->getDepartment()->getId(), $objR->getDepartment()->getId()); - self::assertEquals($obj->getUnit()->getId(), $objR->getUnit()->getId()); + self::assertEquals($obj->responsible, $objR->responsible); + self::assertEquals($obj->deputy, $objR->deputy); + self::assertEquals($obj->department->getId(), $objR->department->getId()); + self::assertEquals($obj->unit->getId(), $objR->unit->getId()); } } diff --git a/tests/Models/ProcessTest.php b/tests/Models/ProcessTest.php index 0959feb..2c7c0d2 100755 --- a/tests/Models/ProcessTest.php +++ b/tests/Models/ProcessTest.php @@ -14,8 +14,6 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; -use Modules\Organization\Models\NullUnit; -use Modules\RiskManagement\Models\NullDepartment; use Modules\RiskManagement\Models\Process; /** @@ -35,36 +33,9 @@ final class ProcessTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $obj->title); self::assertEquals('', $obj->description); self::assertEquals('', $obj->descriptionRaw); - self::assertNull($obj->getDepartment()); - self::assertNull($obj->getUnit()); - self::assertNull($obj->getResponsible()); - self::assertNull($obj->getDeputy()); - } - - /** - * @covers Modules\RiskManagement\Models\Process - * @group module - */ - public function testSetGet() : void - { - $obj = new Process(); - - $obj->title = 'Name'; - self::assertEquals('Name', $obj->title); - - $obj->descriptionRaw = 'Description'; - self::assertEquals('Description', $obj->descriptionRaw); - - $obj->setResponsible(1); - self::assertEquals(1, $obj->getResponsible()); - - $obj->setDeputy(1); - self::assertEquals(1, $obj->getDeputy()); - - $obj->setUnit(new NullUnit(1)); - self::assertEquals(1, $obj->getUnit()->getId()); - - $obj->setDepartment(new NullDepartment(2)); - self::assertEquals(2, $obj->getDepartment()->getId()); + self::assertNull($obj->department); + self::assertNull($obj->unit); + self::assertNull($obj->responsible); + self::assertNull($obj->deputy); } } diff --git a/tests/Models/ProjectMapperTest.php b/tests/Models/ProjectMapperTest.php index 2c9f747..42f7a87 100755 --- a/tests/Models/ProjectMapperTest.php +++ b/tests/Models/ProjectMapperTest.php @@ -29,16 +29,16 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase */ public function testCRUD() : void { - $obj = new Project(); - $obj->setProject(new NullProject(1)); - $obj->setResponsible(1); - $obj->setDeputy(1); + $obj = new Project(); + $obj->project = new NullProject(1); + $obj->responsible = 1; + $obj->deputy = 1; ProjectMapper::create($obj); $objR = ProjectMapper::get($obj->getId()); - self::assertEquals($obj->getProject()->getId(), $objR->getProject()->getId()); - self::assertEquals($obj->getResponsible(), $objR->getResponsible()); - self::assertEquals($obj->getDeputy(), $objR->getDeputy()); + self::assertEquals($obj->project->getId(), $objR->project->getId()); + self::assertEquals($obj->responsible, $objR->responsible); + self::assertEquals($obj->deputy, $objR->deputy); } } diff --git a/tests/Models/ProjectTest.php b/tests/Models/ProjectTest.php index d8295a8..3ec9a43 100755 --- a/tests/Models/ProjectTest.php +++ b/tests/Models/ProjectTest.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; -use Modules\ProjectManagement\Models\NullProject; use Modules\RiskManagement\Models\Project; /** @@ -31,26 +30,8 @@ final class ProjectTest extends \PHPUnit\Framework\TestCase $obj = new Project(); self::assertEquals(0, $obj->getId()); - self::assertNull($obj->getProject()); - self::assertNull($obj->getResponsible()); - self::assertNull($obj->getDeputy()); - } - - /** - * @covers Modules\RiskManagement\Models\Project - * @group module - */ - public function testSetGet() : void - { - $obj = new Project(); - - $obj->setResponsible(1); - self::assertEquals(1, $obj->getResponsible()); - - $obj->setDeputy(1); - self::assertEquals(1, $obj->getDeputy()); - - $obj->setProject(new NullProject(1)); - self::assertEquals(1, $obj->getProject()->getId()); + self::assertNull($obj->project); + self::assertNull($obj->responsible); + self::assertNull($obj->deputy); } } diff --git a/tests/Models/RiskMapperTest.php b/tests/Models/RiskMapperTest.php index e77c942..0381450 100755 --- a/tests/Models/RiskMapperTest.php +++ b/tests/Models/RiskMapperTest.php @@ -43,21 +43,21 @@ final class RiskMapperTest extends \PHPUnit\Framework\TestCase $obj->name = 'Risk Test'; $obj->descriptionRaw = 'Description'; - $obj->setUnit(new NullUnit(1)); - $obj->setDepartment(new NullDepartment(1)); + $obj->unit = new NullUnit(1); + $obj->department = new NullDepartment(1); - $categoryObj = new Category(); - $obj->setCategory($categoryObj); + $categoryObj = new Category(); + $obj->category = $categoryObj; - $processObj = new Process(); - $obj->setProcess($processObj); + $processObj = new Process(); + $obj->process = $processObj; - $projectObj = new Project(); - $projectObj->setProject(new NullProject(1)); - $obj->setProject($projectObj); + $projectObj = new Project(); + $projectObj->project = new NullProject(1); + $obj->project = $projectObj; - $obj->setResponsible(1); - $obj->setDeputy(1); + $obj->responsible = 1; + $obj->deputy = 1; $causeObj = new Cause(); $causeObj->title = 'Risk Test Cause'; @@ -87,13 +87,13 @@ final class RiskMapperTest extends \PHPUnit\Framework\TestCase $objR = RiskMapper::get($obj->getId()); self::assertEquals($obj->name, $objR->name); self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw); - self::assertEquals($obj->getUnit()->getId(), $objR->getUnit()->getId()); - self::assertEquals($obj->getDepartment()->getId(), $objR->getDepartment()->getId()); - self::assertEquals($obj->getCategory()->getId(), $objR->getCategory()->getId()); - self::assertEquals($obj->getProcess()->getId(), $objR->getProcess()->getId()); - self::assertEquals($obj->getResponsible(), $objR->getResponsible()); - self::assertEquals($obj->getDeputy(), $objR->getDeputy()); - self::assertEquals($obj->getProject()->getProject()->getId(), $objR->getProject()->getProject()->getId()); + self::assertEquals($obj->unit->getId(), $objR->unit->getId()); + self::assertEquals($obj->department->getId(), $objR->department->getId()); + self::assertEquals($obj->category->getId(), $objR->category->getId()); + self::assertEquals($obj->process->getId(), $objR->process->getId()); + self::assertEquals($obj->responsible, $objR->responsible); + self::assertEquals($obj->deputy, $objR->deputy); + self::assertEquals($obj->project->project->getId(), $objR->project->project->getId()); $causes = $objR->getCauses(); self::assertEquals($obj->getCauses()[0]->title, \end($causes)->title); diff --git a/tests/Models/RiskObjectMapperTest.php b/tests/Models/RiskObjectMapperTest.php index fa0bcc5..f405648 100755 --- a/tests/Models/RiskObjectMapperTest.php +++ b/tests/Models/RiskObjectMapperTest.php @@ -31,13 +31,13 @@ final class RiskObjectMapperTest extends \PHPUnit\Framework\TestCase $obj = new RiskObject(); $obj->title = 'Name'; $obj->descriptionRaw = 'Description'; - $obj->setRisk(1); + $obj->risk = 1; RiskObjectMapper::create($obj); $objR = RiskObjectMapper::get($obj->getId()); self::assertEquals($obj->title, $objR->title); self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw); - self::assertEquals($obj->getRisk(), $objR->getRisk()); + self::assertEquals($obj->risk, $objR->risk); } } diff --git a/tests/Models/RiskObjectTest.php b/tests/Models/RiskObjectTest.php index 41275c2..423207e 100755 --- a/tests/Models/RiskObjectTest.php +++ b/tests/Models/RiskObjectTest.php @@ -33,24 +33,6 @@ final class RiskObjectTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $obj->title); self::assertEquals('', $obj->description); self::assertEquals('', $obj->descriptionRaw); - self::assertEquals(0, $obj->getRisk()); - } - - /** - * @covers Modules\RiskManagement\Models\RiskObject - * @group module - */ - public function testSetGet() : void - { - $obj = new RiskObject(); - - $obj->title = 'Name'; - self::assertEquals('Name', $obj->title); - - $obj->descriptionRaw = 'Description'; - self::assertEquals('Description', $obj->descriptionRaw); - - $obj->setRisk(1); - self::assertEquals(1, $obj->getRisk()); + self::assertEquals(0, $obj->risk); } } diff --git a/tests/Models/RiskTest.php b/tests/Models/RiskTest.php index a59dbb2..e7c7827 100755 --- a/tests/Models/RiskTest.php +++ b/tests/Models/RiskTest.php @@ -14,12 +14,7 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; -use Modules\Organization\Models\NullDepartment; -use Modules\Organization\Models\NullUnit; use Modules\RiskManagement\Models\Cause; -use Modules\RiskManagement\Models\Department; -use Modules\RiskManagement\Models\NullCategory; -use Modules\RiskManagement\Models\NullProcess; use Modules\RiskManagement\Models\Risk; use Modules\RiskManagement\Models\Solution; @@ -28,80 +23,89 @@ use Modules\RiskManagement\Models\Solution; */ final class RiskTest extends \PHPUnit\Framework\TestCase { + private Risk $risk; + + /** + * {@inheritdoc} + */ + protected function setUp() : void + { + $this->risk = new Risk(); + } + /** * @covers Modules\RiskManagement\Models\Risk * @group module */ public function testDefault() : void { - $obj = new Risk(); - - self::assertEquals(0, $obj->getId()); - self::assertEquals('', $obj->name); - self::assertEquals('', $obj->description); - self::assertEquals('', $obj->descriptionRaw); - self::assertNull($obj->getUnit()); - self::assertNull($obj->getDepartment()); - self::assertNull($obj->getCategory()); - self::assertNull($obj->getProcess()); - self::assertNull($obj->getProject()); - self::assertNull($obj->getResponsible()); - self::assertNull($obj->getDeputy()); - self::assertEquals([], $obj->getHistory()); - self::assertEquals([], $obj->getCauses()); - self::assertEquals([], $obj->getSolutions()); - self::assertEquals([], $obj->getRiskObjects()); - self::assertEquals([], $obj->getMedia()); + self::assertEquals(0, $this->risk->getId()); + self::assertEquals('', $this->risk->name); + self::assertEquals('', $this->risk->description); + self::assertEquals('', $this->risk->descriptionRaw); + self::assertNull($this->risk->unit); + self::assertNull($this->risk->department); + self::assertNull($this->risk->category); + self::assertNull($this->risk->process); + self::assertNull($this->risk->project); + self::assertNull($this->risk->responsible); + self::assertNull($this->risk->deputy); + self::assertEquals([], $this->risk->getHistory()); + self::assertEquals([], $this->risk->getCauses()); + self::assertEquals([], $this->risk->getSolutions()); + self::assertEquals([], $this->risk->getRiskObjects()); + self::assertEquals([], $this->risk->getMedia()); } /** * @covers Modules\RiskManagement\Models\Risk * @group module */ - public function testSetGet() : void + public function testCauseInputOutput() : void { - $obj = new Risk(); + $this->risk->addCause(new Cause()); + self::assertCount(1, $this->risk->getCauses()); + self::assertInstanceOf('\Modules\RiskManagement\Models\Cause', $this->risk->getCauses()[0]); + } - $obj->name = 'Name'; - self::assertEquals('Name', $obj->name); + /** + * @covers Modules\RiskManagement\Models\Risk + * @group module + */ + public function testSolutionInputOutput() : void + { + $this->risk->addSolution(new Solution()); + self::assertCount(1, $this->risk->getSolutions()); + self::assertInstanceOf('\Modules\RiskManagement\Models\Solution', $this->risk->getSolutions()[0]); + } - $obj->descriptionRaw = 'Description'; - self::assertEquals('Description', $obj->descriptionRaw); + /** + * @covers Modules\RiskManagement\Models\Risk + * @group module + */ + public function testRiskObjectInputOutput() : void + { + $this->risk->addRiskObject(2); + self::assertCount(1, $this->risk->getRiskObjects()); + } - $obj->setUnit(new NullUnit(1)); - self::assertEquals(1, $obj->getUnit()->getId()); + /** + * @covers Modules\RiskManagement\Models\Risk + * @group module + */ + public function testHistoryInputOutput() : void + { + $this->risk->addHistory(2); + self::assertCount(1, $this->risk->getHistory()); + } - $obj->setCategory(new NullCategory(3)); - self::assertEquals(3, $obj->getCategory()->getId()); - - $obj->setProcess(new NullProcess(4)); - self::assertEquals(4, $obj->getProcess()->getId()); - - $department = new Department(); - $department->department = new NullDepartment(1); - $obj->setDepartment(new NullDepartment(1)); - - $obj->setResponsible(1); - self::assertEquals(1, $obj->getResponsible()); - - $obj->setDeputy(1); - self::assertEquals(1, $obj->getDeputy()); - - $obj->addCause(new Cause()); - self::assertCount(1, $obj->getCauses()); - self::assertInstanceOf('\Modules\RiskManagement\Models\Cause', $obj->getCauses()[0]); - - $obj->addSolution(new Solution()); - self::assertCount(1, $obj->getSolutions()); - self::assertInstanceOf('\Modules\RiskManagement\Models\Solution', $obj->getSolutions()[0]); - - $obj->addRiskObject(2); - self::assertCount(1, $obj->getRiskObjects()); - - $obj->addHistory(2); - self::assertCount(1, $obj->getHistory()); - - $obj->addMedia(2); - self::assertCount(1, $obj->getMedia()); + /** + * @covers Modules\RiskManagement\Models\Risk + * @group module + */ + public function testMediaInputOutput() : void + { + $this->risk->addMedia(2); + self::assertCount(1, $this->risk->getMedia()); } } diff --git a/tests/Models/SolutionMapperTest.php b/tests/Models/SolutionMapperTest.php index eebe46d..2f1dfc0 100755 --- a/tests/Models/SolutionMapperTest.php +++ b/tests/Models/SolutionMapperTest.php @@ -34,17 +34,17 @@ final class SolutionMapperTest extends \PHPUnit\Framework\TestCase $obj->title = 'Title'; $obj->descriptionRaw = 'Description'; - $obj->setProbability(1); - $obj->setCause(new NullCause(1)); - $obj->setRisk(new NullRisk(1)); + $obj->probability = 1; + $obj->cause = new NullCause(1); + $obj->risk = new NullRisk(1); SolutionMapper::create($obj); $objR = SolutionMapper::get($obj->getId()); self::assertEquals($obj->title, $objR->title); self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw); - self::assertEquals($obj->getProbability(), $objR->getProbability()); - self::assertEquals($obj->getRisk()->getId(), $objR->getRisk()->getId()); - self::assertEquals($obj->getCause()->getId(), $objR->getCause()->getId()); + self::assertEquals($obj->probability, $objR->probability); + self::assertEquals($obj->risk->getId(), $objR->risk->getId()); + self::assertEquals($obj->cause->getId(), $objR->cause->getId()); } } diff --git a/tests/Models/SolutionTest.php b/tests/Models/SolutionTest.php index afb5b81..5096f85 100755 --- a/tests/Models/SolutionTest.php +++ b/tests/Models/SolutionTest.php @@ -14,8 +14,6 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; -use Modules\RiskManagement\Models\NullCause; -use Modules\RiskManagement\Models\NullRisk; use Modules\RiskManagement\Models\Solution; /** @@ -35,32 +33,8 @@ final class SolutionTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $obj->title); self::assertEquals('', $obj->description); self::assertEquals('', $obj->descriptionRaw); - self::assertEquals(0, $obj->getProbability()); - self::assertEquals(0, $obj->getCause()); - self::assertEquals(0, $obj->getRisk()); - } - - /** - * @covers Modules\RiskManagement\Models\Solution - * @group module - */ - public function testSetGet() : void - { - $obj = new Solution(); - - $obj->title = 'Title'; - self::assertEquals('Title', $obj->title); - - $obj->descriptionRaw = 'Description'; - self::assertEquals('Description', $obj->descriptionRaw); - - $obj->setProbability(1); - self::assertEquals(1, $obj->getProbability()); - - $obj->setCause(new NullCause(1)); - self::assertEquals(1, $obj->getCause()->getId()); - - $obj->setRisk(new NullRisk(1)); - self::assertEquals(1, $obj->getRisk()->getId()); + self::assertEquals(0, $obj->probability); + self::assertEquals(0, $obj->cause); + self::assertEquals(0, $obj->risk); } }