mirror of
https://github.com/Karaka-Management/oms-HumanResourceManagement.git
synced 2026-02-15 04:18:39 +00:00
cs fixes, bug fixes, code coverage
This commit is contained in:
parent
d0e973cb26
commit
c1e0f84592
|
|
@ -12,9 +12,7 @@ If you have a good idea for improvement feel free to create a new issue with all
|
||||||
|
|
||||||
### Issues
|
### 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.
|
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.
|
||||||
|
|
||||||
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]`.
|
|
||||||
|
|
||||||
### Code Style
|
### Code Style
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,11 +268,11 @@ final class ApiController extends Controller
|
||||||
*/
|
*/
|
||||||
private function createEmployeeHistoryFromRequest(RequestAbstract $request) : EmployeeHistory
|
private function createEmployeeHistoryFromRequest(RequestAbstract $request) : EmployeeHistory
|
||||||
{
|
{
|
||||||
$history = new EmployeeHistory((int) ($request->getData('employee') ?? 0));
|
$history = new EmployeeHistory((int) ($request->getData('employee') ?? 0));
|
||||||
$history->unit = (int) ($request->getData('unit') ?? 0);
|
$history->unit = (int) ($request->getData('unit') ?? 0);
|
||||||
$history->department = (int) ($request->getData('department') ?? 0);
|
$history->department = (int) ($request->getData('department') ?? 0);
|
||||||
$history->position = (int) ($request->getData('position') ?? 0);
|
$history->position = (int) ($request->getData('position') ?? 0);
|
||||||
$history->start = new \DateTime($request->getData('start') ?? 'now');
|
$history->start = new \DateTime($request->getData('start') ?? 'now');
|
||||||
|
|
||||||
if (!empty($request->getData('end'))) {
|
if (!empty($request->getData('end'))) {
|
||||||
$history->end = new \DateTime($request->getData('end'));
|
$history->end = new \DateTime($request->getData('end'));
|
||||||
|
|
@ -342,8 +342,8 @@ final class ApiController extends Controller
|
||||||
*/
|
*/
|
||||||
private function createEmployeeWorkHistoryFromRequest(RequestAbstract $request) : EmployeeWorkHistory
|
private function createEmployeeWorkHistoryFromRequest(RequestAbstract $request) : EmployeeWorkHistory
|
||||||
{
|
{
|
||||||
$history = new EmployeeWorkHistory((int) ($request->getData('employee') ?? 0));
|
$history = new EmployeeWorkHistory((int) ($request->getData('employee') ?? 0));
|
||||||
$history->start = new \DateTime($request->getData('start') ?? 'now');
|
$history->start = new \DateTime($request->getData('start') ?? 'now');
|
||||||
$history->jobTitle = $request->getData('title');
|
$history->jobTitle = $request->getData('title');
|
||||||
$history->address->name = $request->getData('name');
|
$history->address->name = $request->getData('name');
|
||||||
$history->address->address = $request->getData('address') ?? '';
|
$history->address->address = $request->getData('address') ?? '';
|
||||||
|
|
@ -421,8 +421,8 @@ final class ApiController extends Controller
|
||||||
*/
|
*/
|
||||||
private function createEmployeeEducationHistoryFromRequest(RequestAbstract $request) : EmployeeEducationHistory
|
private function createEmployeeEducationHistoryFromRequest(RequestAbstract $request) : EmployeeEducationHistory
|
||||||
{
|
{
|
||||||
$history = new EmployeeEducationHistory((int) ($request->getData('employee') ?? 0));
|
$history = new EmployeeEducationHistory((int) ($request->getData('employee') ?? 0));
|
||||||
$history->start = new \DateTime($request->getData('start') ?? 'now');
|
$history->start = new \DateTime($request->getData('start') ?? 'now');
|
||||||
$history->educationTitle = $request->getData('title');
|
$history->educationTitle = $request->getData('title');
|
||||||
$history->score = $request->getData('score') ?? '';
|
$history->score = $request->getData('score') ?? '';
|
||||||
$history->passed = (bool) ($request->getData('passed') ?? true);
|
$history->passed = (bool) ($request->getData('passed') ?? true);
|
||||||
|
|
|
||||||
|
|
@ -284,10 +284,10 @@ class Employee implements \JsonSerializable, ArrayableInterface
|
||||||
public function toArray() : array
|
public function toArray() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'profile' => $this->profile,
|
'profile' => $this->profile,
|
||||||
'history' => $this->companyHistory,
|
'history' => $this->companyHistory,
|
||||||
'workHistory' => $this->workHistory,
|
'workHistory' => $this->workHistory,
|
||||||
'educationHistory' => $this->educationHistory,
|
'educationHistory' => $this->educationHistory,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,13 +108,13 @@ class EmployeeEducationHistory implements \JsonSerializable, ArrayableInterface
|
||||||
public function toArray() : array
|
public function toArray() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
|
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
|
||||||
'educationTitle' => $this->educationTitle,
|
'educationTitle' => $this->educationTitle,
|
||||||
'passed' => $this->passed,
|
'passed' => $this->passed,
|
||||||
'score' => $this->score,
|
'score' => $this->score,
|
||||||
'start' => $this->start,
|
'start' => $this->start,
|
||||||
'end' => $this->end,
|
'end' => $this->end,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ namespace Modules\HumanResourceManagement\Models;
|
||||||
|
|
||||||
use Modules\Media\Models\Media;
|
use Modules\Media\Models\Media;
|
||||||
use Modules\Organization\Models\Department;
|
use Modules\Organization\Models\Department;
|
||||||
use Modules\Organization\Models\NullDepartment;
|
|
||||||
use Modules\Organization\Models\NullPosition;
|
|
||||||
use Modules\Organization\Models\NullUnit;
|
|
||||||
use Modules\Organization\Models\Position;
|
use Modules\Organization\Models\Position;
|
||||||
use Modules\Organization\Models\Unit;
|
use Modules\Organization\Models\Unit;
|
||||||
use phpOMS\Contract\ArrayableInterface;
|
use phpOMS\Contract\ArrayableInterface;
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,11 @@ class EmployeeWorkHistory implements \JsonSerializable, ArrayableInterface
|
||||||
public function toArray() : array
|
public function toArray() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
|
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
|
||||||
'jobTitle' => $this->jobTitle,
|
'jobTitle' => $this->jobTitle,
|
||||||
'start' => $this->start,
|
'start' => $this->start,
|
||||||
'end' => $this->end,
|
'end' => $this->end,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Modules\HumanResourceManagement\Models;
|
||||||
*/
|
*/
|
||||||
final class NullEmployeeEducationHistory extends EmployeeEducationHistory
|
final class NullEmployeeEducationHistory extends EmployeeEducationHistory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param int $id Model id
|
* @param int $id Model id
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Modules\HumanResourceManagement\Models;
|
||||||
*/
|
*/
|
||||||
final class NullEmployeeHistory extends EmployeeHistory
|
final class NullEmployeeHistory extends EmployeeHistory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param int $id Model id
|
* @param int $id Model id
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Modules\HumanResourceManagement\Models;
|
||||||
*/
|
*/
|
||||||
final class NullEmployeeWorkHistory extends EmployeeWorkHistory
|
final class NullEmployeeWorkHistory extends EmployeeWorkHistory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param int $id Model id
|
* @param int $id Model id
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@ namespace Modules\HumanResourceManagement\tests\Controller;
|
||||||
|
|
||||||
use Model\CoreSettings;
|
use Model\CoreSettings;
|
||||||
use Modules\Admin\Models\AccountPermission;
|
use Modules\Admin\Models\AccountPermission;
|
||||||
|
use Modules\Organization\Models\Department;
|
||||||
|
use Modules\Organization\Models\DepartmentMapper;
|
||||||
|
use Modules\Organization\Models\NullUnit;
|
||||||
|
use Modules\Organization\Models\Position;
|
||||||
|
use Modules\Organization\Models\PositionMapper;
|
||||||
use phpOMS\Account\Account;
|
use phpOMS\Account\Account;
|
||||||
use phpOMS\Account\AccountManager;
|
use phpOMS\Account\AccountManager;
|
||||||
use phpOMS\Account\PermissionType;
|
use phpOMS\Account\PermissionType;
|
||||||
|
|
@ -23,6 +28,7 @@ use phpOMS\Application\ApplicationAbstract;
|
||||||
use phpOMS\DataStorage\Session\HttpSession;
|
use phpOMS\DataStorage\Session\HttpSession;
|
||||||
use phpOMS\Dispatcher\Dispatcher;
|
use phpOMS\Dispatcher\Dispatcher;
|
||||||
use phpOMS\Event\EventManager;
|
use phpOMS\Event\EventManager;
|
||||||
|
use phpOMS\Localization\ISO3166TwoEnum;
|
||||||
use phpOMS\Message\Http\HttpRequest;
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
use phpOMS\Message\Http\HttpResponse;
|
use phpOMS\Message\Http\HttpResponse;
|
||||||
use phpOMS\Message\Http\RequestStatusCode;
|
use phpOMS\Message\Http\RequestStatusCode;
|
||||||
|
|
@ -30,16 +36,8 @@ use phpOMS\Module\ModuleAbstract;
|
||||||
use phpOMS\Module\ModuleManager;
|
use phpOMS\Module\ModuleManager;
|
||||||
use phpOMS\Router\WebRouter;
|
use phpOMS\Router\WebRouter;
|
||||||
use phpOMS\Uri\HttpUri;
|
use phpOMS\Uri\HttpUri;
|
||||||
use phpOMS\Utils\TestUtils;
|
|
||||||
use phpOMS\Utils\RnG\DateTime;
|
use phpOMS\Utils\RnG\DateTime;
|
||||||
use phpOMS\Localization\ISO3166TwoEnum;
|
use phpOMS\Utils\TestUtils;
|
||||||
use Modules\Organization\Models\Department;
|
|
||||||
use Modules\Organization\Models\DepartmentMapper;
|
|
||||||
use Modules\Organization\Models\NullDepartment;
|
|
||||||
use Modules\Organization\Models\NullUnit;
|
|
||||||
use Modules\Organization\Models\NullPosition;
|
|
||||||
use Modules\Organization\Models\Position;
|
|
||||||
use Modules\Organization\Models\PositionMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox Modules\HumanResourceManagement\tests\Controller\ApiControllerTest: HumanResourceManagement api controller
|
* @testdox Modules\HumanResourceManagement\tests\Controller\ApiControllerTest: HumanResourceManagement api controller
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ final class EmployeeEducationHistoryTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$this->history = new EmployeeEducationHistory();
|
$this->history = new EmployeeEducationHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Modules\HumanResourceManagement\Models\EmployeeEducationHistory
|
* @covers Modules\HumanResourceManagement\Models\EmployeeEducationHistory
|
||||||
* @group module
|
* @group module
|
||||||
|
|
@ -52,22 +53,22 @@ final class EmployeeEducationHistoryTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testSerialize() : void
|
public function testSerialize() : void
|
||||||
{
|
{
|
||||||
$this->history->employee = 2;
|
$this->history->employee = 2;
|
||||||
$this->history->educationTitle = 'title';
|
$this->history->educationTitle = 'title';
|
||||||
$this->history->score = '69';
|
$this->history->score = '69';
|
||||||
$this->history->passed = false;
|
$this->history->passed = false;
|
||||||
|
|
||||||
$serialized = $this->history->jsonSerialize();
|
$serialized = $this->history->jsonSerialize();
|
||||||
unset($serialized['start']);
|
unset($serialized['start']);
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'employee' => 2,
|
'employee' => 2,
|
||||||
'educationTitle' => 'title',
|
'educationTitle' => 'title',
|
||||||
'passed' => false,
|
'passed' => false,
|
||||||
'score' => '69',
|
'score' => '69',
|
||||||
'end' => null,
|
'end' => null,
|
||||||
],
|
],
|
||||||
$serialized
|
$serialized
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\HumanResourceManagement\tests\Models;
|
namespace Modules\HumanResourceManagement\tests\Models;
|
||||||
|
|
||||||
use Modules\Profile\Models\Profile;
|
|
||||||
use Modules\Profile\Models\NullProfile;
|
|
||||||
use Modules\HumanResourceManagement\Models\Employee;
|
use Modules\HumanResourceManagement\Models\Employee;
|
||||||
|
use Modules\HumanResourceManagement\Models\EmployeeEducationHistory;
|
||||||
use Modules\HumanResourceManagement\Models\EmployeeHistory;
|
use Modules\HumanResourceManagement\Models\EmployeeHistory;
|
||||||
use Modules\HumanResourceManagement\Models\EmployeeWorkHistory;
|
use Modules\HumanResourceManagement\Models\EmployeeWorkHistory;
|
||||||
use Modules\HumanResourceManagement\Models\EmployeeEducationHistory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -111,9 +109,9 @@ final class EmployeeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'history' => [],
|
'history' => [],
|
||||||
'workHistory' => [],
|
'workHistory' => [],
|
||||||
'educationHistory' => [],
|
'educationHistory' => [],
|
||||||
],
|
],
|
||||||
$serialized
|
$serialized
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ final class EmployeeWorkHistoryTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$this->history = new EmployeeWorkHistory();
|
$this->history = new EmployeeWorkHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Modules\HumanResourceManagement\Models\EmployeeWorkHistory
|
* @covers Modules\HumanResourceManagement\Models\EmployeeWorkHistory
|
||||||
* @group module
|
* @group module
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ final class EmployeeHistoryTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$this->history = new EmployeeHistory();
|
$this->history = new EmployeeHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Modules\HumanResourceManagement\Models\EmployeeHistory
|
* @covers Modules\HumanResourceManagement\Models\EmployeeHistory
|
||||||
* @group module
|
* @group module
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user