Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/Unit/DayTest.php → tests/DayTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests;

use Illuminate\Support\Carbon;
use TransformStudios\Events\Day;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests;

use Illuminate\Support\Carbon;
use Statamic\Facades\Entry;
use TransformStudios\Events\EventFactory;
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/EventsTest.php → tests/EventsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests;

use Illuminate\Support\Carbon;
use Statamic\Extensions\Pagination\LengthAwarePaginator;
use Statamic\Facades\Entry;
Expand Down
97 changes: 0 additions & 97 deletions tests/Feature/EventsOffsetTest.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests\Http\Controllers;

use Illuminate\Support\Carbon;
use Statamic\Facades\Entry;

Expand Down
76 changes: 76 additions & 0 deletions tests/Feature/TagTest.php → tests/Tags/EventsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests\Tags;

use Illuminate\Support\Carbon;
use Statamic\Facades\Cascade;
use Statamic\Facades\Entry;
Expand Down Expand Up @@ -311,3 +313,77 @@
expect($occurrences[0]->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);
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests\Types;

use Carbon\Carbon;
use Statamic\Facades\Entry;
use TransformStudios\Events\EventFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace TransformStudios\Events\Tests\Types;

use Carbon\Carbon;
use Carbon\CarbonImmutable;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\Entry;
use TransformStudios\Events\EventFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests\Types;

use Carbon\Carbon;
use Statamic\Facades\Entry;
use TransformStudios\Events\EventFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace TransformStudios\Events\Tests\Types;

use Carbon\Carbon;
use Carbon\CarbonImmutable;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\Entry;
use TransformStudios\Events\EventFactory;
use TransformStudios\Events\Types\RecurringEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace TransformStudios\Events\Tests\Types;

use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonTimeZone;
Expand Down