|
8 | 8 | use InvalidArgumentException;
|
9 | 9 | use PHPUnit\Framework\Attributes\DataProvider;
|
10 | 10 | use PHPUnit\Framework\Attributes\Test;
|
| 11 | +use PHPUnit\Framework\Attributes\TestWith; |
11 | 12 | use PHPUnit\Framework\TestCase;
|
12 | 13 | use Spatie\OpeningHours\Day;
|
13 | 14 | use Spatie\OpeningHours\Exceptions\InvalidDateRange;
|
@@ -1647,4 +1648,41 @@ public function testRangesExceptionOverlap()
|
1647 | 1648 | ],
|
1648 | 1649 | ]);
|
1649 | 1650 | }
|
| 1651 | + |
| 1652 | + #[TestWith([true])] |
| 1653 | + #[TestWith([false])] |
| 1654 | + public function testFirstDayMinuteOpenEveryDay(bool $overflow) |
| 1655 | + { |
| 1656 | + $config = [ |
| 1657 | + 'monday' => ['00:01-00:00'], |
| 1658 | + 'tuesday' => ['00:01-00:00'], |
| 1659 | + 'wednesday' => ['00:01-00:00'], |
| 1660 | + 'thursday' => ['00:01-00:00'], |
| 1661 | + 'friday' => ['00:01-00:00'], |
| 1662 | + 'saturday' => ['00:01-00:00'], |
| 1663 | + 'sunday' => ['00:01-00:00'], |
| 1664 | + 'overflow' => $overflow, |
| 1665 | + ]; |
| 1666 | + $openingHoursObject = OpeningHours::create($config); |
| 1667 | + |
| 1668 | + $nextOpen = $openingHoursObject->nextOpen(new DateTimeImmutable('2024-10-22 00:00:00')); |
| 1669 | + |
| 1670 | + $this->assertSame('2024-10-22 00:01:00.000000', $nextOpen->format('Y-m-d H:i:s.u')); |
| 1671 | + |
| 1672 | + $nextOpen = $openingHoursObject->nextOpen(new DateTimeImmutable('2024-10-22 00:00:30')); |
| 1673 | + |
| 1674 | + $this->assertSame('2024-10-22 00:01:00.000000', $nextOpen->format('Y-m-d H:i:s.u')); |
| 1675 | + |
| 1676 | + $nextOpen = $openingHoursObject->nextOpen(new DateTimeImmutable('2024-10-22 00:01:00')); |
| 1677 | + |
| 1678 | + $this->assertSame('2024-10-23 00:01:00.000000', $nextOpen->format('Y-m-d H:i:s.u')); |
| 1679 | + |
| 1680 | + $nextOpen = $openingHoursObject->nextOpen(new DateTimeImmutable('2024-10-22 00:01:00')); |
| 1681 | + |
| 1682 | + $this->assertSame('2024-10-23 00:01:00.000000', $nextOpen->format('Y-m-d H:i:s.u')); |
| 1683 | + |
| 1684 | + $nextOpen = $openingHoursObject->nextOpen(new DateTimeImmutable('2024-10-22 23:59:59.999999')); |
| 1685 | + |
| 1686 | + $this->assertSame('2024-10-23 00:01:00.000000', $nextOpen->format('Y-m-d H:i:s.u')); |
| 1687 | + } |
1650 | 1688 | }
|
0 commit comments