Skip to content

Commit

Permalink
Add test with different interval.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsegura committed Sep 14, 2023
1 parent 98deff2 commit 9994aa1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions wordpress/tests/ShippingDatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,37 @@ public function testTimeSlotToDatePeriodsWithPriorNotice2()
$this->assertCount(12, $ranges);
$this->assertEquals($this->makeDatePeriod('2021-03-17 18:00', '2021-03-17 18:30'), $ranges[0]);
}

public function testTimeSlotToDatePeriodsWithInterval()
{
require_once __DIR__ . '/../src/CoopCycle.php';

$ohs = [
[
"@type" => "OpeningHoursSpecification",
"dayOfWeek" => [ "Tuesday", "Thursday" ],
"opens" => "18:00:00",
"closes" => "19:00:00"
],
[
"@type" => "OpeningHoursSpecification",
"dayOfWeek" => [ "Tuesday", "Thursday" ],
"opens" => "19:00:00",
"closes" => "20:30:00"
],
];

$time_slot = [
'interval' => '7 days',
'openingHoursSpecification' => $ohs,
];

$ranges = \CoopCycle::time_slot_to_date_periods($time_slot, new \DateTime('2019-12-18 12:00:00'));

$this->assertCount(14, $ranges);
$this->assertEquals($this->makeDatePeriod('2019-12-19 18:00', '2019-12-19 19:00'), $ranges[0]);
$this->assertEquals($this->makeDatePeriod('2019-12-19 19:00', '2019-12-19 20:30'), $ranges[1]);
$this->assertEquals($this->makeDatePeriod('2019-12-24 18:00', '2019-12-24 19:00'), $ranges[2]);
$this->assertEquals($this->makeDatePeriod('2019-12-24 19:00', '2019-12-24 20:30'), $ranges[3]);
}
}

0 comments on commit 9994aa1

Please sign in to comment.