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