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 classes
23 *
24 * @group API
25 */
26
27use Orangehrm\Rest\Api\Leave\LeavePeriodAPI;
28use Orangehrm\Rest\Http\Request;
29use Orangehrm\Rest\Http\Response;
30
31class ApiLeavePeriodAPITest extends PHPUnit_Framework_TestCase
32{
33    private $leavePeriodApi;
34
35
36    /**
37     * Set up method
38     */
39    protected function setUp()
40    {
41        $sfEvent = new sfEventDispatcher();
42        $sfRequest = new sfWebRequest($sfEvent);
43        $request = new Request($sfRequest);
44        $this->leavePeriodApi = new LeavePeriodAPI($request);
45
46    }
47
48
49    public function testGetLeavePeriod()
50    {
51        $requestParams = $this->getMockBuilder('\Orangehrm\Rest\Http\RequestParams')
52            ->disableOriginalConstructor()
53            ->setMethods(array('getUrlParam'))
54            ->getMock();
55        $requestParams->expects($this->any())
56            ->method('getUrlParam')
57            ->with('id')
58            ->will($this->returnValue(1));
59
60
61        $leavePeriodList = array(array('2017-01-01','2018-01-01'),array('2018-01-01','2019-01-01'));
62
63
64        $leavePeriodService = $this->getMockBuilder('LeavePeriodService')->getMock();
65        $leavePeriodService->expects($this->any())
66            ->method('getGeneratedLeavePeriodList')
67            ->will($this->returnValue($leavePeriodList));
68
69        $this->leavePeriodApi->setLeavePeriodService($leavePeriodService);
70        $ResponseReturned =  $this->leavePeriodApi->getLeavePeriod();
71        $testResponse = null;
72        $testResponse[] = new Response($leavePeriodList);
73
74        $success =  new Response($leavePeriodList);
75
76        $this->assertEquals($success, $ResponseReturned);
77
78    }
79
80
81}