/** * @param DateTime|null $start * @return DateTime */ public function toDateTime(DateTime $start = null) { $start = $this->getNewStartDate($start); $end = parent::toDateTime($start); if ($this->holidays) { $span = new DateTimeSpan($start, $end); $span = $this->holidays->extendDateTimeSpan($span); return $span->getTo(); } return $end; }
/** * @covers ::extendDateTimeSpan * @dataProvider dataExtendDateTimeSpan */ public function testExtendDateTimeSpan($span, $start_date, $expected) { $holidays = new Holidays([new DateTime('2015-06-17'), new DateTime('2015-06-18'), new DateTime('2015-06-19'), new DateTime('2015-06-20'), new DateTime('2015-06-21'), new DateTime('2015-06-22'), new DateTime('2015-06-23')]); $result = $holidays->extendDateTimeSpan($span, $start_date); $this->assertEquals($expected, $result); }