mirror of
https://github.com/Karaka-Management/oms-RiskManagement.git
synced 2026-01-18 14:48:41 +00:00
test fixes
This commit is contained in:
parent
ad0e7540bf
commit
83c3fc7b9a
|
|
@ -104,7 +104,7 @@ final class BackendController extends Controller
|
|||
|
||||
/** @var \Modules\RiskManagement\Models\Risk $risk */
|
||||
foreach ($view->data['risks'] as $risk) {
|
||||
if ($risk->department->id !== 0) {
|
||||
if ($risk->department !== null && $risk->department->id !== 0) {
|
||||
if (!isset($statsDepartments[$risk->department->name])) {
|
||||
$statsDepartments[$risk->department->name] = [];
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ final class BackendController extends Controller
|
|||
$statsDepartments[$risk->department->name][] = $risk;
|
||||
}
|
||||
|
||||
if ($risk->category->id !== 0) {
|
||||
if ($risk->category !== null && $risk->category->id !== 0) {
|
||||
if (!isset($statsCategories[$view->data['categories'][$risk->category->id]->title])) {
|
||||
$statsCategories[$view->data['categories'][$risk->category->id]->title] = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,13 +42,14 @@ final class CauseMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$risk = new Risk();
|
||||
$risk->name = 'Cause Test Risk';
|
||||
$risk->unit = new NullUnit(1);
|
||||
$risk->unit = 1;
|
||||
$obj->risk = $risk;
|
||||
|
||||
CauseMapper::create()->execute($obj);
|
||||
|
||||
/** @var Cause $objR */
|
||||
$objR = CauseMapper::get()->with('risk')->with('category')->where('id', $obj->id)->execute();
|
||||
self::assertGreaterThan(0, $objR->id);
|
||||
self::assertEquals($obj->title, $objR->title);
|
||||
self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw);
|
||||
//self::assertEquals($obj->getDepartment()->department->id, $objR->getDepartment()->department->id);
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\RiskManagement\tests\Models;
|
||||
|
||||
use Modules\RiskManagement\Models\Department;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\RiskManagement\Models\Department::class)]
|
||||
final class DepartmentTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
#[\PHPUnit\Framework\Attributes\Group('module')]
|
||||
public function testDefault() : void
|
||||
{
|
||||
$obj = new Department();
|
||||
|
||||
self::assertEquals(0, $obj->id);
|
||||
self::assertNull($obj->department);
|
||||
self::assertNull($obj->responsible);
|
||||
self::assertNull($obj->deputy);
|
||||
}
|
||||
}
|
||||
|
|
@ -38,8 +38,8 @@ final class ProcessMapperTest extends \PHPUnit\Framework\TestCase
|
|||
ProcessMapper::create()->execute($obj);
|
||||
|
||||
$objR = ProcessMapper::get()->where('id', $obj->id)->execute();
|
||||
self::assertGreaterThan(0, $objR->id);
|
||||
self::assertEquals($obj->title, $objR->title);
|
||||
self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw);
|
||||
self::assertEquals($obj->responsible, $objR->responsible);
|
||||
self::assertEquals($obj->deputy, $objR->deputy);
|
||||
self::assertEquals($obj->department->id, $objR->department->id);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ final class RiskMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$obj->project = new NullProject(1);
|
||||
|
||||
$obj->responsible = 1;
|
||||
$obj->responsible = new NullAccount(1);
|
||||
$obj->deputy = 1;
|
||||
|
||||
$causeObj = new Cause();
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ final class RiskObjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$obj = new RiskObject();
|
||||
$obj->title = 'Name';
|
||||
$obj->descriptionRaw = 'Description';
|
||||
$obj->risk = 1;
|
||||
|
||||
RiskObjectMapper::create()->execute($obj);
|
||||
|
||||
$objR = RiskObjectMapper::get()->where('id', $obj->id)->execute();
|
||||
self::assertGreaterThan(0, $objR->id);
|
||||
self::assertEquals($obj->title, $objR->title);
|
||||
self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw);
|
||||
self::assertEquals($obj->risk, $objR->risk);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ final class RiskTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals('', $this->risk->name);
|
||||
self::assertEquals('', $this->risk->description);
|
||||
self::assertEquals('', $this->risk->descriptionRaw);
|
||||
self::assertNull($this->risk->unit);
|
||||
self::assertEquals(0, $this->risk->unit);
|
||||
self::assertNull($this->risk->department);
|
||||
self::assertNull($this->risk->category);
|
||||
self::assertNull($this->risk->process);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\RiskManagement\tests\Models;
|
||||
|
||||
use Modules\RiskManagement\Models\NullCause;
|
||||
use Modules\RiskManagement\Models\NullRisk;
|
||||
use Modules\RiskManagement\Models\Cause;
|
||||
use Modules\RiskManagement\Models\Risk;
|
||||
use Modules\RiskManagement\Models\Solution;
|
||||
use Modules\RiskManagement\Models\SolutionMapper;
|
||||
|
||||
|
|
@ -33,12 +33,13 @@ final class SolutionMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$obj->title = 'Title';
|
||||
$obj->descriptionRaw = 'Description';
|
||||
$obj->probability = 1;
|
||||
$obj->cause = new NullCause(1);
|
||||
$obj->risk = new NullRisk(1);
|
||||
$obj->cause = new Cause();
|
||||
$obj->risk = new Risk();
|
||||
|
||||
SolutionMapper::create()->execute($obj);
|
||||
|
||||
$objR = SolutionMapper::get()->where('id', $obj->id)->execute();
|
||||
self::assertGreaterThan(0, $objR->id);
|
||||
self::assertEquals($obj->title, $objR->title);
|
||||
self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw);
|
||||
self::assertEquals($obj->probability, $objR->probability);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user