Skip to content

Commit

Permalink
Add tests for #258
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Nov 17, 2024
1 parent bfa3956 commit 0be810f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/OpeningHoursOverflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,32 @@ public function overflow_on_simple_ranges()
$this->assertFalse($openWithOverflow->isOpenAt($time));
$this->assertFalse($openWithoutOverflow->isOpenAt($time));
}

#[Test]
public function overflow_next_close()
{
$openingHours = OpeningHours::create([
'overflow' => true,
'monday' => ['18:00-05:00'], // 2024-11-11
'tuesday' => ['17:00-06:00'], // 2024-11-12
]);

$nextClose = $openingHours->nextClose(new DateTime('2024-11-12 04:00:00'));

$this->assertSame('2024-11-12 05:00', $nextClose->format('Y-m-d H:i'));

$nextClose = $openingHours->nextClose(new DateTime('2024-11-12 05:30:00'));

$this->assertSame('2024-11-13 06:00', $nextClose->format('Y-m-d H:i'));

$openingHours = OpeningHours::create([
'overflow' => true,
'monday' => ['18:00-22:00', '23:00-05:00'], // 2024-11-11
'tuesday' => ['17:00-06:00'], // 2024-11-12
]);

$nextClose = $openingHours->nextClose(new DateTime('2024-11-12 04:00:00'));

$this->assertSame('2024-11-12 05:00', $nextClose->format('Y-m-d H:i'));
}
}

0 comments on commit 0be810f

Please sign in to comment.