mirror of
https://github.com/Karaka-Management/oms-HumanResourceManagement.git
synced 2026-01-28 19:58:40 +00:00
bug fixes / dbmapper fixes
This commit is contained in:
parent
f1e7cac376
commit
9d3a0a7887
|
|
@ -106,11 +106,11 @@ class EmployeeHistory implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public function __construct($employee = 0)
|
||||
{
|
||||
$this->employee = $employee;
|
||||
$this->start = new \DateTime('now');
|
||||
$this->unit = new NullUnit();
|
||||
$this->employee = $employee;
|
||||
$this->start = new \DateTime('now');
|
||||
$this->unit = new NullUnit();
|
||||
$this->department = new NullDepartment();
|
||||
$this->position = new NullPosition();
|
||||
$this->position = new NullPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -76,26 +76,26 @@ final class EmployeeMapper extends DataMapperFactory
|
|||
*/
|
||||
public const HAS_MANY = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'hr_staff_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'hr_staff_media_media',
|
||||
'self' => 'hr_staff_media_item',
|
||||
],
|
||||
'companyHistory' => [
|
||||
'mapper' => EmployeeHistoryMapper::class,
|
||||
'table' => 'hr_staff_history', // @todo: is this requried? This is stored in the mapper already. In other places I'm not using this, either use it everywhere or nowhere. Using the mapper is slower but protects us from table name changes!
|
||||
'table' => 'hr_staff_history',
|
||||
'self' => 'hr_staff_history_staff',
|
||||
'external' => null,
|
||||
],
|
||||
'workHistory' => [
|
||||
'mapper' => EmployeeWorkHistoryMapper::class,
|
||||
'table' => 'hr_staff_work_history', // @todo: is this requried? This is stored in the mapper already. In other places I'm not using this, either use it everywhere or nowhere. Using the mapper is slower but protects us from table name changes!
|
||||
'table' => 'hr_staff_work_history',
|
||||
'self' => 'hr_staff_work_history_staff',
|
||||
'external' => null,
|
||||
],
|
||||
'educationHistory' => [
|
||||
'mapper' => EmployeeEducationHistoryMapper::class,
|
||||
'table' => 'hr_staff_education_history', // @todo: is this requried? This is stored in the mapper already. In other places I'm not using this, either use it everywhere or nowhere. Using the mapper is slower but protects us from table name changes!
|
||||
'table' => 'hr_staff_education_history',
|
||||
'self' => 'hr_staff_education_history_staff',
|
||||
'external' => null,
|
||||
],
|
||||
|
|
@ -116,21 +116,4 @@ final class EmployeeMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='hr_staff_id';
|
||||
|
||||
/**
|
||||
* Get the employee from an account
|
||||
*
|
||||
* @param int $account Account to get the employee for
|
||||
*
|
||||
* @return ReadMapper
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getFromAccount(int $account) : ReadMapper
|
||||
{
|
||||
return self::get()
|
||||
->with('profile')
|
||||
->with('profile/account')
|
||||
->where('profile/account', $account);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,6 @@ final class EmployeeMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$employeeR = EmployeeMapper::get()->where('id', $employee->getId())->execute();
|
||||
self::assertEquals($employee->profile->getId(), $employeeR->profile->getId());
|
||||
self::assertGreaterThan(0, EmployeeMapper::getFromAccount(1)->limit(1)->execute()->getId());
|
||||
self::assertGreaterThan(0, EmployeeMapper::get()->with('profile')->where('profile/account', 1)->limit(1)->execute()->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ final class EmployeeHistoryTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(0, $this->history->getId());
|
||||
self::assertNull($this->history->end);
|
||||
self::assertEquals(0, $this->history->employee);
|
||||
self::assertNull($this->history->position);
|
||||
self::assertNull($this->history->unit);
|
||||
self::assertNull($this->history->department);
|
||||
self::assertInstanceOf('\Modules\Organization\Models\NullPosition', $this->history->position);
|
||||
self::assertInstanceOf('\Modules\Organization\Models\NullUnit', $this->history->unit);
|
||||
self::assertInstanceOf('\Modules\Organization\Models\NullDepartment', $this->history->department);
|
||||
self::assertInstanceOf('\DateTime', $this->history->start);
|
||||
}
|
||||
|
||||
|
|
@ -56,14 +56,14 @@ final class EmployeeHistoryTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$serialized = $this->history->jsonSerialize();
|
||||
unset($serialized['start']);
|
||||
unset($serialized['unit']);
|
||||
unset($serialized['department']);
|
||||
unset($serialized['position']);
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'employee' => 2,
|
||||
'unit' => null,
|
||||
'department' => null,
|
||||
'position' => null,
|
||||
'end' => null,
|
||||
],
|
||||
$serialized
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user