Skip to content

Commit 646e259

Browse files
authored
Move tests around (#137)
1 parent 2b541a3 commit 646e259

11 files changed

Lines changed: 94 additions & 99 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests;
4+
35
use Illuminate\Support\Carbon;
46
use TransformStudios\Events\Day;
57

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests;
4+
35
use Illuminate\Support\Carbon;
46
use Statamic\Facades\Entry;
57
use TransformStudios\Events\EventFactory;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests;
4+
35
use Illuminate\Support\Carbon;
46
use Statamic\Extensions\Pagination\LengthAwarePaginator;
57
use Statamic\Facades\Entry;

tests/Feature/EventsOffsetTest.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

tests/Feature/IcsControllerTest.php renamed to tests/Http/Contollers/IcsControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests\Http\Controllers;
4+
35
use Illuminate\Support\Carbon;
46
use Statamic\Facades\Entry;
57

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests\Tags;
4+
35
use Illuminate\Support\Carbon;
46
use Statamic\Facades\Cascade;
57
use Statamic\Facades\Entry;
@@ -311,3 +313,77 @@
311313
expect($occurrences[0]->start->isAfter($occurrences[1]->start))->toBeTrue();
312314
expect($occurrences[1]->start->isAfter($occurrences[2]->start))->toBeTrue();
313315
});
316+
test('can offset upcoming occurrences', function () {
317+
Carbon::setTestNow(now()->setTimeFromTimeString('10:00'));
318+
319+
$this->tag
320+
->setContext([])
321+
->setParameters([
322+
'collection' => 'events',
323+
'limit' => 5,
324+
'offset' => 2,
325+
]);
326+
327+
$occurrences = $this->tag->upcoming();
328+
329+
expect($occurrences)->toHaveCount(3);
330+
});
331+
332+
test('can offset between occurrences', function () {
333+
Carbon::setTestNow(now()->setTimeFromTimeString('10:00'));
334+
335+
$this->tag->setContext([])
336+
->setParameters([
337+
'collection' => 'events',
338+
'from' => Carbon::now()->toDateString(),
339+
'to' => Carbon::now()->addWeek(3),
340+
'offset' => 2,
341+
]);
342+
343+
$occurrences = $this->tag->between();
344+
345+
expect($occurrences)->toHaveCount(2);
346+
});
347+
348+
test('can offset today occurrences', function () {
349+
Carbon::setTestNow(now()->setTimeFromTimeString('12:01'));
350+
351+
Entry::make()
352+
->collection('events')
353+
->slug('single-event')
354+
->data([
355+
'title' => 'Single Event',
356+
'start_date' => Carbon::now()->toDateString(),
357+
'start_time' => '13:00',
358+
'end_time' => '15:00',
359+
])->save();
360+
361+
$this->tag->setContext([])
362+
->setParameters([
363+
'collection' => 'events',
364+
'offset' => 1,
365+
]);
366+
367+
expect($this->tag->today())->toHaveCount(1);
368+
369+
$this->tag->setContext([])
370+
->setParameters([
371+
'collection' => 'events',
372+
'ignore_finished' => true,
373+
'offset' => 1,
374+
]);
375+
376+
expect($this->tag->today())->toHaveCount(0);
377+
});
378+
379+
test('can offset single day occurrences', function () {
380+
Carbon::setTestNow(now()->setTimeFromTimeString('10:00'));
381+
382+
$this->tag->setContext([])
383+
->setParameters([
384+
'collection' => 'events',
385+
'offset' => 1,
386+
]);
387+
388+
expect($this->tag->today())->toHaveCount(0);
389+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests\Types;
4+
35
use Carbon\Carbon;
46
use Statamic\Facades\Entry;
57
use TransformStudios\Events\EventFactory;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests\Types;
4+
35
use Carbon\Carbon;
46
use Carbon\CarbonImmutable;
5-
use PHPUnit\Framework\Attributes\Test;
67
use Statamic\Facades\Entry;
78
use TransformStudios\Events\EventFactory;
89

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests\Types;
4+
35
use Carbon\Carbon;
46
use Statamic\Facades\Entry;
57
use TransformStudios\Events\EventFactory;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3+
namespace TransformStudios\Events\Tests\Types;
4+
35
use Carbon\Carbon;
46
use Carbon\CarbonImmutable;
5-
use PHPUnit\Framework\Attributes\Test;
67
use Statamic\Facades\Entry;
78
use TransformStudios\Events\EventFactory;
89
use TransformStudios\Events\Types\RecurringEvent;

0 commit comments

Comments
 (0)