Differential D15927 Diff 38352 src/applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php
| Show All 10 Lines | final class PhabricatorCalendarHolidayTestCase extends PhabricatorTestCase { | ||||
| protected function willRunTests() { | protected function willRunTests() { | ||||
| parent::willRunTests(); | parent::willRunTests(); | ||||
| id(new PhabricatorCalendarHoliday()) | id(new PhabricatorCalendarHoliday()) | ||||
| ->setDay('2012-01-02') | ->setDay('2012-01-02') | ||||
| ->setName(pht('International Testing Day')) | ->setName(pht('International Testing Day')) | ||||
| ->save(); | ->save(); | ||||
| } | } | ||||
| public function testNthBusinessDay() { | |||||
| $map = array( | |||||
| array('2011-12-30', 1, '2012-01-03'), | |||||
| array('2012-01-01', 1, '2012-01-03'), | |||||
| array('2012-01-01', 0, '2012-01-01'), | |||||
| array('2012-01-01', -1, '2011-12-30'), | |||||
| array('2012-01-04', -1, '2012-01-03'), | |||||
| ); | |||||
| foreach ($map as $val) { | |||||
| list($date, $n, $expect) = $val; | |||||
| $actual = PhabricatorCalendarHoliday::getNthBusinessDay( | |||||
| strtotime($date), | |||||
| $n); | |||||
| $this->assertEqual( | |||||
| $expect, | |||||
| date('Y-m-d', $actual), | |||||
| pht("%d business days since '%s'", $n, $date)); | |||||
| } | |||||
| } | |||||
| } | } | ||||