From 554ab93432eb78cd89d109683b38073a81ff0c93 Mon Sep 17 00:00:00 2001 From: edalzell Date: Fri, 24 Oct 2025 16:33:04 -0700 Subject: [PATCH] Move tests around --- tests/{Unit => }/DayTest.php | 2 + tests/{Unit => }/EventFactoryTest.php | 2 + tests/{Unit => }/EventsTest.php | 2 + tests/Feature/EventsOffsetTest.php | 97 ------------------- .../Contollers}/IcsControllerTest.php | 2 + .../TagTest.php => Tags/EventsTest.php} | 76 +++++++++++++++ tests/{Unit => Types}/MultiDayEventsTest.php | 2 + .../RecurringDailyEventsTest.php | 3 +- tests/{Unit => Types}/RecurringEventsTest.php | 2 + .../RecurringEveryXEventsTest.php | 3 +- tests/{Unit => Types}/SingleDayEventsTest.php | 2 + 11 files changed, 94 insertions(+), 99 deletions(-) rename tests/{Unit => }/DayTest.php (94%) rename tests/{Unit => }/EventFactoryTest.php (98%) rename tests/{Unit => }/EventsTest.php (99%) delete mode 100644 tests/Feature/EventsOffsetTest.php rename tests/{Feature => Http/Contollers}/IcsControllerTest.php (99%) rename tests/{Feature/TagTest.php => Tags/EventsTest.php} (81%) rename tests/{Unit => Types}/MultiDayEventsTest.php (98%) rename tests/{Unit => Types}/RecurringDailyEventsTest.php (99%) rename tests/{Unit => Types}/RecurringEventsTest.php (98%) rename tests/{Unit => Types}/RecurringEveryXEventsTest.php (99%) rename tests/{Unit => Types}/SingleDayEventsTest.php (98%) diff --git a/tests/Unit/DayTest.php b/tests/DayTest.php similarity index 94% rename from tests/Unit/DayTest.php rename to tests/DayTest.php index 7aa4843..6781d88 100755 --- a/tests/Unit/DayTest.php +++ b/tests/DayTest.php @@ -1,5 +1,7 @@ collection('events') - ->slug('recurring-event') - ->id('recurring-event') - ->data([ - 'title' => 'Recurring Event', - 'start_date' => Carbon::now()->toDateString(), - 'start_time' => '11:00', - 'end_time' => '12:00', - 'recurrence' => 'weekly', - 'categories' => ['one'], - ])->save(); - - $this->tag = app(Events::class); -}); - -test('can offset upcoming occurrences', function () { - Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); - - $this->tag - ->setContext([]) - ->setParameters([ - 'collection' => 'events', - 'limit' => 5, - 'offset' => 2, - ]); - - $occurrences = $this->tag->upcoming(); - - expect($occurrences)->toHaveCount(3); -}); - -test('can offset between occurrences', function () { - Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); - - $this->tag->setContext([]) - ->setParameters([ - 'collection' => 'events', - 'from' => Carbon::now()->toDateString(), - 'to' => Carbon::now()->addWeek(3), - 'offset' => 2, - ]); - - $occurrences = $this->tag->between(); - - expect($occurrences)->toHaveCount(2); -}); - -test('can offset today occurrences', function () { - Carbon::setTestNow(now()->setTimeFromTimeString('12:01')); - - Entry::make() - ->collection('events') - ->slug('single-event') - ->data([ - 'title' => 'Single Event', - 'start_date' => Carbon::now()->toDateString(), - 'start_time' => '13:00', - 'end_time' => '15:00', - ])->save(); - - $this->tag->setContext([]) - ->setParameters([ - 'collection' => 'events', - 'offset' => 1, - ]); - - expect($this->tag->today())->toHaveCount(1); - - $this->tag->setContext([]) - ->setParameters([ - 'collection' => 'events', - 'ignore_finished' => true, - 'offset' => 1, - ]); - - expect($this->tag->today())->toHaveCount(0); -}); - -test('can offset single day occurrences', function () { - Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); - - $this->tag->setContext([]) - ->setParameters([ - 'collection' => 'events', - 'offset' => 1, - ]); - - expect($this->tag->today())->toHaveCount(0); -}); diff --git a/tests/Feature/IcsControllerTest.php b/tests/Http/Contollers/IcsControllerTest.php similarity index 99% rename from tests/Feature/IcsControllerTest.php rename to tests/Http/Contollers/IcsControllerTest.php index 7f3b8fd..d484c15 100755 --- a/tests/Feature/IcsControllerTest.php +++ b/tests/Http/Contollers/IcsControllerTest.php @@ -1,5 +1,7 @@ start->isAfter($occurrences[1]->start))->toBeTrue(); expect($occurrences[1]->start->isAfter($occurrences[2]->start))->toBeTrue(); }); +test('can offset upcoming occurrences', function () { + Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); + + $this->tag + ->setContext([]) + ->setParameters([ + 'collection' => 'events', + 'limit' => 5, + 'offset' => 2, + ]); + + $occurrences = $this->tag->upcoming(); + + expect($occurrences)->toHaveCount(3); +}); + +test('can offset between occurrences', function () { + Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); + + $this->tag->setContext([]) + ->setParameters([ + 'collection' => 'events', + 'from' => Carbon::now()->toDateString(), + 'to' => Carbon::now()->addWeek(3), + 'offset' => 2, + ]); + + $occurrences = $this->tag->between(); + + expect($occurrences)->toHaveCount(2); +}); + +test('can offset today occurrences', function () { + Carbon::setTestNow(now()->setTimeFromTimeString('12:01')); + + Entry::make() + ->collection('events') + ->slug('single-event') + ->data([ + 'title' => 'Single Event', + 'start_date' => Carbon::now()->toDateString(), + 'start_time' => '13:00', + 'end_time' => '15:00', + ])->save(); + + $this->tag->setContext([]) + ->setParameters([ + 'collection' => 'events', + 'offset' => 1, + ]); + + expect($this->tag->today())->toHaveCount(1); + + $this->tag->setContext([]) + ->setParameters([ + 'collection' => 'events', + 'ignore_finished' => true, + 'offset' => 1, + ]); + + expect($this->tag->today())->toHaveCount(0); +}); + +test('can offset single day occurrences', function () { + Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); + + $this->tag->setContext([]) + ->setParameters([ + 'collection' => 'events', + 'offset' => 1, + ]); + + expect($this->tag->today())->toHaveCount(0); +}); diff --git a/tests/Unit/MultiDayEventsTest.php b/tests/Types/MultiDayEventsTest.php similarity index 98% rename from tests/Unit/MultiDayEventsTest.php rename to tests/Types/MultiDayEventsTest.php index b1b80e6..9690dcd 100755 --- a/tests/Unit/MultiDayEventsTest.php +++ b/tests/Types/MultiDayEventsTest.php @@ -1,5 +1,7 @@