From e578c0c84dfc65c9dd9f73ddf9e09aa8cf015ad7 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 25 Apr 2024 17:11:56 +0000 Subject: [PATCH] fix tests --- Admin/Install/db.json | 21 --------------------- Models/Solution.php | 7 ++++++- tests/Models/RiskMapperTest.php | 10 ++-------- tests/Models/SolutionMapperTest.php | 4 ++-- 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 8420b9a..5a00afd 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -9,21 +9,6 @@ "primary": true, "autoincrement": true }, - "riskmngmt_category_name": { - "name": "riskmngmt_category_name", - "type": "VARCHAR(255)", - "null": false - }, - "riskmngmt_category_description": { - "name": "riskmngmt_category_description", - "type": "TEXT", - "null": false - }, - "riskmngmt_category_descriptionraw": { - "name": "riskmngmt_category_descriptionraw", - "type": "TEXT", - "null": false - }, "riskmngmt_category_parent": { "name": "riskmngmt_category_parent", "type": "INT", @@ -559,12 +544,6 @@ "type": "INT", "null": false }, - "riskmngmt_solution_effect": { - "name": "riskmngmt_solution_effect", - "type": "INT", - "default": null, - "null": true - }, "riskmngmt_solution_cause": { "name": "riskmngmt_solution_cause", "type": "INT", diff --git a/Models/Solution.php b/Models/Solution.php index 21ba2b5..610dcc3 100755 --- a/Models/Solution.php +++ b/Models/Solution.php @@ -54,5 +54,10 @@ class Solution public ?Cause $cause = null; - public ?Risk $risk = null; + public Risk $risk; + + public function __construct() + { + $this->risk = new Risk(); + } } diff --git a/tests/Models/RiskMapperTest.php b/tests/Models/RiskMapperTest.php index a725470..aa0de3a 100755 --- a/tests/Models/RiskMapperTest.php +++ b/tests/Models/RiskMapperTest.php @@ -41,14 +41,8 @@ final class RiskMapperTest extends \PHPUnit\Framework\TestCase $obj->descriptionRaw = 'Description'; $obj->unit = 1; $obj->department = new NullDepartment(1); - - $categoryObj = new Category(); - $obj->category = $categoryObj; - - $processObj = new Process(); - $obj->process = $processObj; - - $obj->project = new NullProject(1); + $obj->category = new Category(); + $obj->process = new Process(); $obj->responsible = new NullAccount(1); $obj->deputy = new NullAccount(1); diff --git a/tests/Models/SolutionMapperTest.php b/tests/Models/SolutionMapperTest.php index 7086077..78b343c 100755 --- a/tests/Models/SolutionMapperTest.php +++ b/tests/Models/SolutionMapperTest.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\RiskManagement\tests\Models; use Modules\RiskManagement\Models\Cause; +use Modules\RiskManagement\Models\NullRisk; use Modules\RiskManagement\Models\Risk; use Modules\RiskManagement\Models\Solution; use Modules\RiskManagement\Models\SolutionMapper; @@ -33,8 +34,7 @@ final class SolutionMapperTest extends \PHPUnit\Framework\TestCase $obj->title = 'Title'; $obj->descriptionRaw = 'Description'; $obj->probability = 1; - $obj->cause = new Cause(); - $obj->risk = new Risk(); + $obj->risk = new NullRisk(1); SolutionMapper::create()->execute($obj); self::assertGreaterThan(0, $obj->id);