-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathEventsOffsetTest.php
More file actions
97 lines (77 loc) · 2.46 KB
/
EventsOffsetTest.php
File metadata and controls
97 lines (77 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
use Illuminate\Support\Carbon;
use Statamic\Facades\Entry;
use TransformStudios\Events\Tags\Events;
beforeEach(function () {
Entry::make()
->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);
});