fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-26 03:03:31 +00:00
parent 0e00b8ac76
commit 9fbefe76e7
5 changed files with 11 additions and 14 deletions

View File

@ -137,8 +137,8 @@ final class ApiController extends Controller
$unit->descriptionRaw = $request->getDataString('description') ?? $unit->descriptionRaw; $unit->descriptionRaw = $request->getDataString('description') ?? $unit->descriptionRaw;
$unit->description = Markdown::parse($request->getDataString('description') ?? $unit->descriptionRaw); $unit->description = Markdown::parse($request->getDataString('description') ?? $unit->descriptionRaw);
$parent = (int) $request->getData('parent'); $parent = $request->getDataInt('parent') ?? 0;
$unit->parent = empty($parent) ? $unit->parent : new NullUnit($parent); $unit->parent = $parent === 0 ? $unit->parent : new NullUnit($parent);
$unit->setStatus($request->getDataInt('status') ?? $unit->getStatus()); $unit->setStatus($request->getDataInt('status') ?? $unit->getStatus());
return $unit; return $unit;

View File

@ -43,10 +43,10 @@ class Department implements \JsonSerializable
/** /**
* Parent * Parent
* *
* @var self * @var null|self
* @since 1.0.0 * @since 1.0.0
*/ */
public self $parent; public ?self $parent = null;
/** /**
* Status * Status
@ -90,7 +90,6 @@ class Department implements \JsonSerializable
public function __construct(string $name = '') public function __construct(string $name = '')
{ {
$this->name = $name; $this->name = $name;
$this->parent = new NullDepartment();
$this->unit = new NullUnit(); $this->unit = new NullUnit();
} }

View File

@ -43,10 +43,10 @@ class Position implements \JsonSerializable
/** /**
* Parent * Parent
* *
* @var Position * @var null|Position
* @since 1.0.0 * @since 1.0.0
*/ */
public self $parent; public ?self $parent = null;
/** /**
* Department * Department
@ -87,7 +87,6 @@ class Position implements \JsonSerializable
*/ */
public function __construct() public function __construct()
{ {
$this->parent = new NullPosition();
$this->department = new NullDepartment(); $this->department = new NullDepartment();
} }
@ -129,7 +128,7 @@ class Position implements \JsonSerializable
'description' => $this->description, 'description' => $this->description,
'descriptionRaw' => $this->descriptionRaw, 'descriptionRaw' => $this->descriptionRaw,
'department' => $this->department ?? new NullDepartment(), 'department' => $this->department ?? new NullDepartment(),
'parent' => $this->parent ?? null, 'parent' => $this->parent,
]; ];
} }

View File

@ -56,10 +56,10 @@ class Unit implements \JsonSerializable
/** /**
* Parent * Parent
* *
* @var Unit * @var null|Unit
* @since 1.0.0 * @since 1.0.0
*/ */
public self $parent; public ?self $parent;
/** /**
* Description. * Description.
@ -97,7 +97,6 @@ class Unit implements \JsonSerializable
public function __construct() public function __construct()
{ {
$this->image = new NullMedia(); $this->image = new NullMedia();
$this->parent = new NullUnit();
$this->mainAddress = new NullAddress(); $this->mainAddress = new NullAddress();
} }
@ -150,7 +149,7 @@ class Unit implements \JsonSerializable
'status' => $this->status, 'status' => $this->status,
'description' => $this->description, 'description' => $this->description,
'descriptionRaw' => $this->descriptionRaw, 'descriptionRaw' => $this->descriptionRaw,
'parent' => $this->parent ?? null, 'parent' => $this->parent,
'image' => $this->image, 'image' => $this->image,
]; ];
} }

View File

@ -82,7 +82,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$this->app->accountManager->add($account); $this->app->accountManager->add($account);
$this->app->router = new WebRouter(); $this->app->router = new WebRouter();
$this->module = $this->app->moduleManager->get('Organization'); $this->module = $this->app->moduleManager->get('Organization', 'Api');
TestUtils::setMember($this->module, 'app', $this->app); TestUtils::setMember($this->module, 'app', $this->app);
} }