diff --git a/src/Types/MultiDayEvent.php b/src/Types/MultiDayEvent.php index 2f0485a..876ee8a 100644 --- a/src/Types/MultiDayEvent.php +++ b/src/Types/MultiDayEvent.php @@ -22,6 +22,7 @@ public function __construct(Entry $event, private bool $collapseMultiDays) parent::__construct($event); $this->days = collect($this->event->days) + ->sortBy('date') ->map(fn (Values $day) => new Day( $day->all(), $this->timezone['timezone'], diff --git a/tests/Unit/MultiDayEventsTest.php b/tests/Unit/MultiDayEventsTest.php index 48a0b78..eca8184 100755 --- a/tests/Unit/MultiDayEventsTest.php +++ b/tests/Unit/MultiDayEventsTest.php @@ -32,11 +32,6 @@ protected function setUp(): void ->data([ 'recurrence' => 'multi_day', 'days' => [ - [ - 'date' => '2019-11-23', - 'start_time' => '19:00', - 'end_time' => '21:00', - ], [ 'date' => '2019-11-24', 'start_time' => '11:00', @@ -47,6 +42,11 @@ protected function setUp(): void 'start_time' => '11:00', 'end_time' => '15:00', ], + [ + 'date' => '2019-11-23', + 'start_time' => '19:00', + 'end_time' => '21:00', + ], ], 'timezone' => 'America/Vancouver', ]); @@ -118,6 +118,23 @@ public function canGetStart() ); } + #[Test] + public function canGetEnd() + { + $this->assertEquals( + Carbon::parse('2019-11-25 15:00')->shiftTimezone('America/Vancouver'), + $this->event->end() + ); + $this->assertEquals( + Carbon::parse('2019-11-21 23:59:59.999999')->shiftTimezone('America/Vancouver'), + $this->allDayEvent->end() + ); + $this->assertEquals( + Carbon::parse('2019-11-21 23:59:00')->shiftTimezone('America/Vancouver')->timezone, + $this->event->end()->timezone + ); + } + #[Test] public function noOccurrencesIfNowAfterEndDate() {