public function testJsonSerializeWithOpeningIntervalsCache() { $day = new SpecialDay(Days::MONDAY, function (\DateTime $date) { return [['12:00', '18:00']]; }); $monday = new \DateTime('2015-05-25'); $day->isTimeWithinOpeningHours(new Time('14', '00'), $monday); $this->assertJsonStringEqualsJsonFile(__DIR__ . '/Expected/SpecialDay/testJsonSerializeWithOpeningIntervalsCache.json', json_encode($day)); }
public function testIsTimeWithin() { $monday = new \DateTime('2015-05-25'); $day = new SpecialDay(Days::MONDAY, function (\DateTime $date) { if ('2015-05-25' == $date->format('Y-m-d')) { return [['14:00', '17:00'], ['06:00', '07:00']]; } return [['12:00', '18:00']]; }); $this->assertTrue($day->isTimeWithinOpeningHours(new Time('14', '00'), $monday)); $this->assertTrue($day->isTimeWithinOpeningHours(new Time('16', '59'), $monday)); $this->assertTrue($day->isTimeWithinOpeningHours(new Time('06', '59'), $monday)); $this->assertFalse($day->isTimeWithinOpeningHours(new Time('08', '00'), $monday)); $this->assertFalse($day->isTimeWithinOpeningHours(new Time('20', '00'), $monday)); }