mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-01-26 14:48:40 +00:00
autofixes
This commit is contained in:
parent
447b702672
commit
c8ee1176fe
|
|
@ -50,7 +50,7 @@ final class Installer extends InstallerAbstract
|
|||
*/
|
||||
private static function installDefaultUnit() : void
|
||||
{
|
||||
$unit = new Unit();
|
||||
$unit = new Unit();
|
||||
$unit->name = 'Orange Management';
|
||||
|
||||
UnitMapper::create($unit);
|
||||
|
|
|
|||
|
|
@ -127,12 +127,12 @@ final class ApiController extends Controller
|
|||
private function updateUnitFromRequest(RequestAbstract $request) : Unit
|
||||
{
|
||||
/** @var Unit $unit */
|
||||
$unit = UnitMapper::get((int) $request->getData('id'));
|
||||
$unit->name = (string) ($request->getData('name') ?? $unit->name);
|
||||
$unit = UnitMapper::get((int) $request->getData('id'));
|
||||
$unit->name = (string) ($request->getData('name') ?? $unit->name);
|
||||
$unit->descriptionRaw = (string) ($request->getData('description') ?? $unit->descriptionRaw);
|
||||
$unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw));
|
||||
$unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw));
|
||||
|
||||
$parent = (int) $request->getData('parent');
|
||||
$parent = (int) $request->getData('parent');
|
||||
$unit->parent = !empty($parent) ? new NullUnit($parent) : $unit->parent;
|
||||
$unit->setStatus((int) ($request->getData('status') ?? $unit->getStatus()));
|
||||
|
||||
|
|
@ -206,12 +206,12 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createUnitFromRequest(RequestAbstract $request) : Unit
|
||||
{
|
||||
$unit = new Unit();
|
||||
$unit->name = (string) $request->getData('name');
|
||||
$unit = new Unit();
|
||||
$unit->name = (string) $request->getData('name');
|
||||
$unit->descriptionRaw = (string) ($request->getData('description') ?? '');
|
||||
$unit->description = Markdown::parse((string) ($request->getData('description') ?? ''));
|
||||
$unit->description = Markdown::parse((string) ($request->getData('description') ?? ''));
|
||||
|
||||
$parent = (int) $request->getData('parent');
|
||||
$parent = (int) $request->getData('parent');
|
||||
$unit->parent = new NullUnit($parent);
|
||||
$unit->setStatus((int) $request->getData('status'));
|
||||
|
||||
|
|
@ -362,15 +362,15 @@ final class ApiController extends Controller
|
|||
private function updatePositionFromRequest(RequestAbstract $request) : Position
|
||||
{
|
||||
/** @var Position $position */
|
||||
$position = PositionMapper::get((int) $request->getData('id'));
|
||||
$position->name = (string) ($request->getData('name') ?? $position->name);
|
||||
$position = PositionMapper::get((int) $request->getData('id'));
|
||||
$position->name = (string) ($request->getData('name') ?? $position->name);
|
||||
$position->descriptionRaw = (string) ($request->getData('description') ?? $position->descriptionRaw);
|
||||
$position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw));
|
||||
$position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw));
|
||||
|
||||
$parent = (int) $request->getData('parent');
|
||||
$parent = (int) $request->getData('parent');
|
||||
$position->parent = !empty($parent) ? new NullPosition($parent) : $position->parent;
|
||||
|
||||
$department = (int) $request->getData('department');
|
||||
$department = (int) $request->getData('department');
|
||||
$position->department = !empty($department) ? new NullDepartment($department) : $position->department;
|
||||
$position->setStatus((int) ($request->getData('status') ?? $position->getStatus()));
|
||||
|
||||
|
|
@ -423,16 +423,16 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createPositionFromRequest(RequestAbstract $request) : Position
|
||||
{
|
||||
$position = new Position();
|
||||
$position = new Position();
|
||||
$position->name = (string) ($request->getData('name'));
|
||||
$position->setStatus((int) $request->getData('status'));
|
||||
$position->descriptionRaw = (string) ($request->getData('description') ?? '');
|
||||
$position->description = Markdown::parse((string) ($request->getData('description') ?? ''));
|
||||
$position->description = Markdown::parse((string) ($request->getData('description') ?? ''));
|
||||
|
||||
$parent = (int) $request->getData('parent');
|
||||
$parent = (int) $request->getData('parent');
|
||||
$position->parent = new NullPosition($parent);
|
||||
|
||||
$department = (int) $request->getData('department');
|
||||
$department = (int) $request->getData('department');
|
||||
$position->department = new NullDepartment($department);
|
||||
|
||||
return $position;
|
||||
|
|
@ -519,16 +519,16 @@ final class ApiController extends Controller
|
|||
private function updateDepartmentFromRequest(RequestAbstract $request) : Department
|
||||
{
|
||||
/** @var Department $department */
|
||||
$department = DepartmentMapper::get((int) $request->getData('id'));
|
||||
$department->name = (string) ($request->getData('name') ?? $department->name);
|
||||
$department = DepartmentMapper::get((int) $request->getData('id'));
|
||||
$department->name = (string) ($request->getData('name') ?? $department->name);
|
||||
$department->descriptionRaw = (string) ($request->getData('description') ?? $department->descriptionRaw);
|
||||
$department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw));
|
||||
$department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw));
|
||||
|
||||
$parent = (int) $request->getData('parent');
|
||||
$parent = (int) $request->getData('parent');
|
||||
$department->parent = !empty($parent) ? new NullDepartment($parent) : $department->parent;
|
||||
$department->setStatus((int) ($request->getData('status') ?? $department->getStatus()));
|
||||
|
||||
$unit = (int) $request->getData('unit');
|
||||
$unit = (int) $request->getData('unit');
|
||||
$department->unit = !empty($unit) ? new NullUnit($unit) : $department->unit;
|
||||
|
||||
return $department;
|
||||
|
|
@ -601,15 +601,15 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createDepartmentFromRequest(RequestAbstract $request) : Department
|
||||
{
|
||||
$department = new Department();
|
||||
$department = new Department();
|
||||
$department->name = (string) $request->getData('name');
|
||||
$department->setStatus((int) $request->getData('status'));
|
||||
|
||||
$parent = (int) $request->getData('parent');
|
||||
$department->parent = new NullDepartment($parent);
|
||||
$department->unit = new NullUnit((int) ($request->getData('unit') ?? 1));
|
||||
$parent = (int) $request->getData('parent');
|
||||
$department->parent = new NullDepartment($parent);
|
||||
$department->unit = new NullUnit((int) ($request->getData('unit') ?? 1));
|
||||
$department->descriptionRaw = (string) ($request->getData('description') ?? '');
|
||||
$department->description = Markdown::parse((string) ($request->getData('description') ?? ''));
|
||||
$department->description = Markdown::parse((string) ($request->getData('description') ?? ''));
|
||||
|
||||
return $department;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ class Department implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->name = $name;
|
||||
$this->parent = new NullDepartment();
|
||||
$this->unit = new NullUnit();
|
||||
$this->unit = new NullUnit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ final class NullDepartment extends Department
|
|||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->id = $id;
|
||||
$this->unit = new NullUnit();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ final class NullUnit extends Unit
|
|||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->id = $id;
|
||||
$this->image = new NullMedia();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Position implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->parent = new NullPosition();
|
||||
$this->parent = new NullPosition();
|
||||
$this->department = new NullDepartment();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->image = new NullMedia();
|
||||
$this->image = new NullMedia();
|
||||
$this->parent = new NullUnit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
use Modules\Organization\Models\Status;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$department = new Department();
|
||||
$department->name = 'Management';
|
||||
$department = new Department();
|
||||
$department->name = 'Management';
|
||||
$department->description = 'Description';
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->unit = new NullUnit(1);
|
||||
|
||||
$id = DepartmentMapper::create($department);
|
||||
|
||||
|
|
@ -56,67 +56,67 @@ class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$first = 2;
|
||||
|
||||
/* 2 */
|
||||
$department = new Department();
|
||||
$department->name = 'HR';
|
||||
$department = new Department();
|
||||
$department->name = 'HR';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 3 */
|
||||
$department = new Department();
|
||||
$department->name = 'QM';
|
||||
$department = new Department();
|
||||
$department->name = 'QM';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 4 */
|
||||
$department = new Department();
|
||||
$department->name = 'Sales';
|
||||
$department = new Department();
|
||||
$department->name = 'Sales';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 5 */
|
||||
$department = new Department();
|
||||
$department->name = 'Shipping';
|
||||
$department = new Department();
|
||||
$department->name = 'Shipping';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first + 3);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first + 3);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 6 */
|
||||
$department = new Department();
|
||||
$department->name = 'Purchase';
|
||||
$department = new Department();
|
||||
$department->name = 'Purchase';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 7 */
|
||||
$department = new Department();
|
||||
$department->name = 'Arrival';
|
||||
$department = new Department();
|
||||
$department->name = 'Arrival';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first + 5);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first + 5);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 8 */
|
||||
$department = new Department();
|
||||
$department->name = 'Accounting';
|
||||
$department = new Department();
|
||||
$department->name = 'Accounting';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
/* 9 */
|
||||
$department = new Department();
|
||||
$department->name = 'Production';
|
||||
$department = new Department();
|
||||
$department->name = 'Production';
|
||||
$department->description = 'Description';
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
$department->parent = new NullDepartment($first);
|
||||
$department->unit = new NullUnit(1);
|
||||
DepartmentMapper::create($department);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,12 +112,12 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->department->name = 'Name';
|
||||
$this->department->description = 'Description';
|
||||
$this->department->name = 'Name';
|
||||
$this->department->description = 'Description';
|
||||
$this->department->descriptionRaw = 'DescriptionRaw';
|
||||
$this->department->setStatus(Status::ACTIVE);
|
||||
$this->department->parent = ($p = new NullDepartment(1));
|
||||
$this->department->unit = ($u = new NullUnit(1));
|
||||
$this->department->unit = ($u = new NullUnit(1));
|
||||
|
||||
self::assertEquals($this->department->toArray(), $this->department->jsonSerialize());
|
||||
self::assertEquals(
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ class PositionMapperTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$position = new Position();
|
||||
$position->name = 'CEO';
|
||||
$position = new Position();
|
||||
$position->name = 'CEO';
|
||||
$position->description = 'Description';
|
||||
|
||||
$id = PositionMapper::create($position);
|
||||
|
|
@ -53,59 +53,59 @@ class PositionMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$first = 2;
|
||||
|
||||
/* 4 */
|
||||
$position = new Position();
|
||||
$position->name = 'CFO';
|
||||
$position = new Position();
|
||||
$position->name = 'CFO';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($first);
|
||||
$id = PositionMapper::create($position);
|
||||
$position->parent = new NullPosition($first);
|
||||
$id = PositionMapper::create($position);
|
||||
|
||||
/* 5 */
|
||||
$position = new Position();
|
||||
$position->name = 'Accountant';
|
||||
$position = new Position();
|
||||
$position->name = 'Accountant';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($id);
|
||||
$position->parent = new NullPosition($id);
|
||||
PositionMapper::create($position);
|
||||
|
||||
/* 6 */
|
||||
$position = new Position();
|
||||
$position->name = 'Controller';
|
||||
$position = new Position();
|
||||
$position->name = 'Controller';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($id);
|
||||
$position->parent = new NullPosition($id);
|
||||
PositionMapper::create($position);
|
||||
|
||||
/* 7 */
|
||||
$position = new Position();
|
||||
$position->name = 'Sales Director';
|
||||
$position = new Position();
|
||||
$position->name = 'Sales Director';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($first);
|
||||
$position->parent = new NullPosition($first);
|
||||
PositionMapper::create($position);
|
||||
|
||||
/* 8 */
|
||||
$position = new Position();
|
||||
$position->name = 'Purchase Director';
|
||||
$position = new Position();
|
||||
$position->name = 'Purchase Director';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($first);
|
||||
$position->parent = new NullPosition($first);
|
||||
PositionMapper::create($position);
|
||||
|
||||
/* 9 */
|
||||
$position = new Position();
|
||||
$position->name = 'Territory Manager';
|
||||
$position = new Position();
|
||||
$position->name = 'Territory Manager';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($first + 4);
|
||||
$position->parent = new NullPosition($first + 4);
|
||||
PositionMapper::create($position);
|
||||
|
||||
/* 10 */
|
||||
$position = new Position();
|
||||
$position->name = 'Territory Sales Assistant';
|
||||
$position = new Position();
|
||||
$position->name = 'Territory Sales Assistant';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($first + 6);
|
||||
$position->parent = new NullPosition($first + 6);
|
||||
PositionMapper::create($position);
|
||||
|
||||
/* 11 */
|
||||
$position = new Position();
|
||||
$position->name = 'Domestic Sales Manager';
|
||||
$position = new Position();
|
||||
$position->name = 'Domestic Sales Manager';
|
||||
$position->description = 'Description';
|
||||
$position->parent = new NullPosition($first + 4);
|
||||
$position->parent = new NullPosition($first + 4);
|
||||
PositionMapper::create($position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ class PositionTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->position->name = 'Name';
|
||||
$this->position->description = 'Description';
|
||||
$this->position->name = 'Name';
|
||||
$this->position->description = 'Description';
|
||||
$this->position->descriptionRaw = 'DescriptionRaw';
|
||||
$this->position->setStatus(Status::ACTIVE);
|
||||
$this->position->parent = ($p = new NullPosition(1));
|
||||
$this->position->parent = ($p = new NullPosition(1));
|
||||
$this->position->department = ($d = new NullDepartment(1));
|
||||
|
||||
self::assertEquals($this->position->toArray(), $this->position->jsonSerialize());
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ class UnitMapperTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testCRUD() : void
|
||||
{
|
||||
$unit = new Unit();
|
||||
$unit->name = 'Scrooge Inc.';
|
||||
$unit = new Unit();
|
||||
$unit->name = 'Scrooge Inc.';
|
||||
$unit->description = 'Description';
|
||||
$unit->parent = new NullUnit(1);
|
||||
$unit->parent = new NullUnit(1);
|
||||
|
||||
$id = UnitMapper::create($unit);
|
||||
|
||||
|
|
|
|||
|
|
@ -112,12 +112,12 @@ class UnitTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->unit->name = 'Name';
|
||||
$this->unit->description = 'Description';
|
||||
$this->unit->name = 'Name';
|
||||
$this->unit->description = 'Description';
|
||||
$this->unit->descriptionRaw = 'DescriptionRaw';
|
||||
$this->unit->setStatus(Status::ACTIVE);
|
||||
$this->unit->parent = ($p = new NullUnit(1));
|
||||
$this->unit->image = ($i = new NullMedia(1));
|
||||
$this->unit->image = ($i = new NullMedia(1));
|
||||
|
||||
self::assertEquals($this->unit->toArray(), $this->unit->jsonSerialize());
|
||||
self::assertEquals(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user