-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
855e80a
commit 5b69747
Showing
3 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/plugins/orangehrmAdminPlugin/test/Api/WorkShiftEmployeeAPITest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace OrangeHRM\Tests\Admin\Api; | ||
|
||
use OrangeHRM\Admin\Api\WorkShiftEmployeeAPI; | ||
use OrangeHRM\Framework\Services; | ||
use OrangeHRM\Tests\Util\EndpointIntegrationTestCase; | ||
use OrangeHRM\Tests\Util\Integration\TestCaseParams; | ||
|
||
/** | ||
* @group Admin | ||
* @group APIv2 | ||
*/ | ||
class WorkShiftEmployeeAPITest extends EndpointIntegrationTestCase | ||
{ | ||
/** | ||
* @dataProvider dataProviderForTestGetAll | ||
*/ | ||
public function testGetAll(TestCaseParams $testCaseParams): void | ||
{ | ||
$this->populateFixtures('WorkShiftEmployeeAPI.yaml'); | ||
$this->createKernelWithMockServices([Services::AUTH_USER => $this->getMockAuthUser($testCaseParams)]); | ||
$this->registerServices($testCaseParams); | ||
$api = $this->getApiEndpointMock(WorkShiftEmployeeAPI::class, $testCaseParams); | ||
$this->assertValidTestCase($api, 'getAll', $testCaseParams); | ||
} | ||
|
||
public function dataProviderForTestGetAll(): array | ||
{ | ||
return $this->getTestCases('WorkShiftEmployeeTestCases.yaml', 'GetAll'); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/plugins/orangehrmAdminPlugin/test/fixtures/WorkShiftEmployeeAPI.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Config: | ||
- { name: 'authorize_user_role_manager_class', value: 'BasicUserRoleManager' } | ||
|
||
Subunit: | ||
- { id: 1, name: 'Organization', description: 'company description', lft: 1, rgt: 14, level: 0 } | ||
- { id: 2, name: 'Open Source', description: 'department description', lft: 2, rgt: 5, level: 1 } | ||
- { id: 3, name: 'Development', description: 'sub department description', lft: 6, rgt: 7, level: 1 } | ||
|
||
JobTitle: | ||
- { id: 1, job_title: 'Software Engineer - Intern', is_deleted: 0 } | ||
|
||
JobCategory: | ||
- { id: 1, name: "Officials and Managers" } | ||
|
||
Nationality: | ||
- { "id": 167, "name": "Sri Lanka" } | ||
|
||
EmploymentStatus: | ||
- { "id": 1, "name": "Intern" } | ||
|
||
TerminationReason: | ||
- { "id": "1","name": "Other" } | ||
- { "id": "2","name": "Retired" } | ||
- { "id": "3","name": "Contract Not Renewed" } | ||
- { "id": "4","name": "Resigned - Company Requested" } | ||
- { "id": "5","name": "Resigned - Self Proposed" } | ||
- { "id": "6","name": "Resigned" } | ||
- { "id": "7","name": "Deceased" } | ||
- { "id": "8","name": "Physically Disabled/Compensated" } | ||
- { "id": "9","name": "Laid-off" } | ||
- { "id": "10","name": "Dismissed" } | ||
|
||
EmployeeTerminationRecord: | ||
- {"id":"1","reason_id":"3","termination_date":"2022-03-01","note":null} | ||
- {"id":"2","reason_id":"3","termination_date":"2022-03-01","note":null} | ||
- {"id":"3","reason_id":"2","termination_date":"2022-05-01","note":null} | ||
|
||
Employee: | ||
- {"emp_number":"1","employee_id":"0001","emp_lastname":"Admin","emp_firstname":"Devi"} | ||
- {"emp_number":"2","employee_id":"0002","emp_lastname":"Kumara","emp_firstname":"Rajitha"}OHRm5 | ||
- {"emp_number":"3","employee_id":"0003","emp_lastname":"de Silva","emp_firstname":"Devishke","emp_status": 1,"job_title_code": 1,"work_station": 3} | ||
- {"emp_number":"4","employee_id":"0004","emp_lastname":"Employee","emp_firstname":"Purged","termination_id":"1","purged_at":"2022-03-07 03:48:17"} | ||
- {"emp_number":"5","employee_id":"0005","emp_lastname":"Perera","emp_firstname":"Sharuka"} | ||
- {"emp_number":"6","employee_id":"0006","emp_lastname":"Gamage","emp_firstname":"Chenuka","termination_id":"2"} | ||
- {"emp_number": "7","employee_id": "0007","emp_lastname": "Anderson","emp_firstname": "Linda","emp_middle_name": "Jane", "termination_id":"3"} | ||
|
||
EmpPicture: | ||
- { emp_number: 1, epic_picture: 'testblob', epic_filename: 'profile.jpeg', epic_type: 'image/jpeg', epic_file_size: '20692', epic_file_width: '200', epic_file_height: '200'} | ||
|
||
UserRole: | ||
- { id: 1, name: Admin, display_name: Admin, is_assignable: 1, is_predefined: 1 } | ||
- { id: 2, name: ESS, display_name: ESS, is_assignable: 1, is_predefined: 1 } | ||
- { id: 3, name: Supervisor, display_name: Supervisor, is_assignable: 0, is_predefined: 1 } | ||
|
||
User: | ||
- {"id":"1","user_role_id":"1","emp_number":"1","user_name":"admin"} | ||
- {"id":"2","user_role_id":"2","emp_number":"2","user_name":"rajitha"} | ||
- {"id":"3","user_role_id":"2","emp_number":"3","user_name":"devishke"} | ||
- {"id":"4","user_role_id":"2","emp_number":"5","user_name":"sharuka"} | ||
|
||
WorkShift: | ||
- {"id":"1","name":"Shift 1","hours_per_day":"8.00","start_time":"09:00:00","end_time":"17:00:00"} | ||
|
||
EmployeeWorkShift: | ||
- {"work_shift_id":"1","emp_number":"1"} |
101 changes: 101 additions & 0 deletions
101
src/plugins/orangehrmAdminPlugin/test/fixtures/testcases/WorkShiftEmployeeTestCases.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
GetAll: | ||
'get employee with nameOrId=Raj': | ||
userId: 1 | ||
services: | ||
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService | ||
query: | ||
nameOrId: Raj | ||
data: [ | ||
{ | ||
empNumber: 2, | ||
lastName: Kumara, | ||
firstName: Rajitha, | ||
middleName: '', | ||
employeeId: 0002, | ||
terminationId: null | ||
} | ||
] | ||
meta: | ||
total: 1 | ||
|
||
'get purged employees': | ||
userId: 1 | ||
services: | ||
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService | ||
query: | ||
nameOrId: Purged | ||
data: [ ] | ||
meta: | ||
total: 0 | ||
|
||
'get terminated employees': | ||
userId: 1 | ||
services: | ||
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService | ||
query: | ||
nameOrId: Linda | ||
data: [ ] | ||
meta: | ||
total: 0 | ||
|
||
'get employee with nameOrId=Dev': | ||
userId: 1 | ||
services: | ||
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService | ||
query: | ||
nameOrId: Dev | ||
data: [ | ||
{ | ||
empNumber: 3, | ||
lastName: de Silva, | ||
firstName: Devishke, | ||
middleName: '', | ||
employeeId: 0003, | ||
terminationId: null | ||
} | ||
] | ||
meta: | ||
total: 2 #employee count is not considering assigned employees | ||
|
||
'get already assigned employee': | ||
userId: 1 | ||
services: | ||
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService | ||
query: | ||
nameOrId: Devi Admin | ||
data: [ ] | ||
meta: | ||
total: 1 #employee count is not considering assigned employees | ||
|
||
'without query params': | ||
userId: 1 | ||
services: | ||
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService | ||
data: [ | ||
{ | ||
empNumber: 3, | ||
lastName: de Silva, | ||
firstName: Devishke, | ||
middleName: '', | ||
employeeId: 0003, | ||
terminationId: null, | ||
}, | ||
{ | ||
empNumber: 2, | ||
lastName: Kumara, | ||
firstName: Rajitha, | ||
middleName: '', | ||
employeeId: 0002, | ||
terminationId: null, | ||
}, | ||
{ | ||
empNumber: 5, | ||
lastName: Perera, | ||
firstName: Sharuka, | ||
middleName: '', | ||
employeeId: 0005, | ||
terminationId: null, | ||
} | ||
] | ||
meta: | ||
total: 4 #employee count is not considering assigned employees |