From 5b69747abcc341f78af3da7aefbbcc8da301f32b Mon Sep 17 00:00:00 2001 From: devishke-orange Date: Sun, 26 May 2024 17:38:27 +0530 Subject: [PATCH] OHRM5X-2560: add test cases --- .../test/Api/WorkShiftEmployeeAPITest.php | 32 ++++++ .../test/fixtures/WorkShiftEmployeeAPI.yaml | 65 +++++++++++ .../testcases/WorkShiftEmployeeTestCases.yaml | 101 ++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 src/plugins/orangehrmAdminPlugin/test/Api/WorkShiftEmployeeAPITest.php create mode 100644 src/plugins/orangehrmAdminPlugin/test/fixtures/WorkShiftEmployeeAPI.yaml create mode 100644 src/plugins/orangehrmAdminPlugin/test/fixtures/testcases/WorkShiftEmployeeTestCases.yaml diff --git a/src/plugins/orangehrmAdminPlugin/test/Api/WorkShiftEmployeeAPITest.php b/src/plugins/orangehrmAdminPlugin/test/Api/WorkShiftEmployeeAPITest.php new file mode 100644 index 0000000000..2a53f5c340 --- /dev/null +++ b/src/plugins/orangehrmAdminPlugin/test/Api/WorkShiftEmployeeAPITest.php @@ -0,0 +1,32 @@ +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'); + } +} diff --git a/src/plugins/orangehrmAdminPlugin/test/fixtures/WorkShiftEmployeeAPI.yaml b/src/plugins/orangehrmAdminPlugin/test/fixtures/WorkShiftEmployeeAPI.yaml new file mode 100644 index 0000000000..57bbead1fe --- /dev/null +++ b/src/plugins/orangehrmAdminPlugin/test/fixtures/WorkShiftEmployeeAPI.yaml @@ -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"} \ No newline at end of file diff --git a/src/plugins/orangehrmAdminPlugin/test/fixtures/testcases/WorkShiftEmployeeTestCases.yaml b/src/plugins/orangehrmAdminPlugin/test/fixtures/testcases/WorkShiftEmployeeTestCases.yaml new file mode 100644 index 0000000000..71968b8c73 --- /dev/null +++ b/src/plugins/orangehrmAdminPlugin/test/fixtures/testcases/WorkShiftEmployeeTestCases.yaml @@ -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 \ No newline at end of file