1<?php
2/**
3 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
4 * all the essential functionalities required for any enterprise.
5 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
6 *
7 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
8 * the GNU General Public License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with this program;
16 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA  02110-1301, USA
18 */
19
20
21/**
22 * Test class of Api/EmployeeService
23 *
24 * @group API
25 */
26use Orangehrm\Rest\Api\Pim\Entity\Employee;
27use Orangehrm\Rest\Api\Pim\Entity\Supervisor;
28
29class ApiEmployeeTest extends PHPUnit_Framework_TestCase
30{
31
32    /**
33     * Set up method
34     */
35    protected function setUp()
36    {
37
38    }
39
40    public function testToArray()
41    {
42
43
44        $supervisor = new Supervisor("Nina Lewis", 1);
45        $supervisorsList = array();
46        $supervisorsList[] = $supervisor;
47
48        $testEmployeeArray = array(
49
50            'firstName' => 'Martin',
51            'middleName' => 'Riggs',
52            'employeeId' => '1',
53            'lastName' => 'Dan',
54            'fullName' => 'Martin Riggs Dan',
55            'status' => 'active',
56            'dob' => '2016-05-04',
57            'unit' => '',
58            'jobTitle' => 'Engineer',
59            'code' => '1',
60            'driversLicenseNumber' => '',
61            'licenseExpiryDate' => null,
62            'maritalStatus' => null,
63            'gender' => null,
64            'otherId' => null,
65            'nationality' => null,
66            'supervisor' => $supervisorsList,
67            'sinNumber'  => null,
68            'ssnNumber'  => null
69
70        );
71
72        \OrangeConfig::getInstance()->setAppConfValue(\ConfigService::KEY_PIM_SHOW_SIN, true);
73        \OrangeConfig::getInstance()->setAppConfValue(\ConfigService::KEY_PIM_SHOW_SSN, true);
74
75        $employee = new Employee('Martin', 'Riggs', 'Dan', '1');
76        $employee->setEmployeeFullName('Martin Riggs Dan');
77        $employee->setEmployeeStatus('active');
78        $employee->setEmpBirthDate('2016-05-04');
79        $employee->setUnit('');
80        $employee->setJobTitle('Engineer');
81        $employee->setEmployeeNumber('1');
82
83        $employee->setSupervisors($supervisorsList);
84
85        $this->assertEquals($testEmployeeArray, $employee->toArray());
86
87        \OrangeConfig::getInstance()->setAppConfValue(\ConfigService::KEY_PIM_SHOW_SIN, false);
88        unset($testEmployeeArray['sinNumber']);
89        $this->assertEquals($testEmployeeArray, $employee->toArray());
90
91        \OrangeConfig::getInstance()->setAppConfValue(\ConfigService::KEY_PIM_SHOW_SSN, false);
92        unset($testEmployeeArray['ssnNumber']);
93        $this->assertEquals($testEmployeeArray, $employee->toArray());
94    }
95
96}