コード例 #1
0
 /**
  * Get Leave Period List
  * @return string
  */
 public function getLeavePeriodList()
 {
     $choices = array();
     $leavePeriodService = new LeavePeriodService();
     $leavePeriodList = $leavePeriodService->getGeneratedLeavePeriodList();
     foreach ($leavePeriodList as $leavePeriod) {
         $choices[set_datepicker_date_format($leavePeriod[0]) . '$$' . set_datepicker_date_format($leavePeriod[1])] = set_datepicker_date_format($leavePeriod[0]) . ' - ' . set_datepicker_date_format($leavePeriod[1]);
     }
     return $choices;
 }
コード例 #2
0
 public function testGetGeneratedLeavePeriodListCase2()
 {
     $leavePeriodHistory = new LeavePeriodHistory();
     $leavePeriodHistory->setLeavePeriodStartMonth(2);
     $leavePeriodHistory->setLeavePeriodStartDay(1);
     $leavePeriodHistory->setCreatedAt('2010-01-01');
     $this->leavePeriodService->saveLeavePeriodHistory($leavePeriodHistory);
     $leavePeriodHistory = new LeavePeriodHistory();
     $leavePeriodHistory->setLeavePeriodStartMonth(1);
     $leavePeriodHistory->setLeavePeriodStartDay(1);
     $leavePeriodHistory->setCreatedAt('2010-01-02');
     $this->leavePeriodService->saveLeavePeriodHistory($leavePeriodHistory);
     $leavePeriodHistory = new LeavePeriodHistory();
     $leavePeriodHistory->setLeavePeriodStartMonth(1);
     $leavePeriodHistory->setLeavePeriodStartDay(2);
     $leavePeriodHistory->setCreatedAt('2010-01-02');
     $this->leavePeriodService->saveLeavePeriodHistory($leavePeriodHistory);
     // work around for cached generated leave period list
     $newLeavePeriodService = new LeavePeriodService();
     $newLeavePeriodService->setLeaveEntitlementService($this->leavePeriodService->getLeaveEntitlementService());
     $result = $newLeavePeriodService->getGeneratedLeavePeriodList(null, true);
     $expected = array(array('2009-02-01', '2011-01-01'), array('2011-01-02', '2012-01-01'), array('2012-01-02', '2013-01-01'), array('2013-01-02', '2014-01-01'));
     // extend range till next year end:
     $now = new DateTime();
     $nextYear = $now->format('Y') + 1;
     $this->assertTrue($nextYear > 2012, 'System clock set to past!. Test should be run with system date 2012 or later.');
     if ($nextYear > 2013) {
         for ($year = 2014; $year <= $nextYear; $year++) {
             $expected[] = array($year . '-01-02', $year + 1 . '-01-01');
         }
     }
     $this->assertEquals($expected, $result);
 }