Skip to content

Commit 888d4d4

Browse files
committed
more tests and fixes
1 parent f482354 commit 888d4d4

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

src/Http/Controllers/IcsController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function __invoke(Request $request)
5151

5252
if ($entry) {
5353
return $this->downloadIcs(
54-
EventFactory::createFromEntry($entry)->toICalendarEvents()
54+
EventFactory::createFromEntry($entry)->toICalendarEvents(),
55+
$entry->title
5556
);
5657
}
5758
}

tests/Feature/IcsControllerTest.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,70 @@ public function can_create_single_day_recurring_event_ics_file()
8080
]))->assertStatus(404);
8181
}
8282

83+
#[Test]
84+
public function can_create_ics_with_single_date_recurrence()
85+
{
86+
Carbon::setTestNow(now()->addDay()->setTimeFromTimeString('10:00'));
87+
88+
Entry::make()
89+
->collection('events')
90+
->slug('recurring-event')
91+
->id('the-recurring-id')
92+
->data([
93+
'title' => 'Recurring Event',
94+
'start_date' => Carbon::now()->toDateString(),
95+
'start_time' => '11:00',
96+
'end_time' => '12:00',
97+
'recurrence' => 'weekly',
98+
'location' => 'The Location',
99+
'description' => 'The description',
100+
'link' => 'https://transformstudios.com'
101+
])->save();
102+
103+
$response = $this->get(route('statamic.events.ics.show', [
104+
'date' => now()->toDateString(),
105+
'event' => 'the-recurring-id',
106+
]))->assertDownload('recurring-event.ics');
107+
108+
109+
$this->assertStringContainsString('DTSTART:'.now()->setTimeFromTimeString('11:00')->format('Ymd\THis'), $response->streamedContent());
110+
$this->assertStringContainsString('LOCATION:The Location', $response->streamedContent());
111+
$this->assertStringContainsString('DESCRIPTION:The description', $response->streamedContent());
112+
$this->assertStringContainsString('URL:https://transformstudios.com', $response->streamedContent());
113+
114+
}
115+
116+
#[Test]
117+
public function can_create_ics_with_recurrence()
118+
{
119+
Carbon::setTestNow(now()->addDay()->setTimeFromTimeString('10:00'));
120+
121+
Entry::make()
122+
->collection('events')
123+
->slug('recurring-event')
124+
->id('the-recurring-id')
125+
->data([
126+
'title' => 'Recurring Event',
127+
'start_date' => Carbon::now()->toDateString(),
128+
'start_time' => '11:00',
129+
'end_time' => '12:00',
130+
'recurrence' => 'weekly',
131+
'location' => 'The Location',
132+
'description' => 'The description',
133+
'link' => 'https://transformstudios.com'
134+
])->save();
135+
136+
$response = $this->get(route('statamic.events.ics.show', [
137+
'event' => 'the-recurring-id',
138+
]))->assertDownload('recurring-event.ics');
139+
140+
$this->assertStringContainsString('DTSTART:'.now()->setTimeFromTimeString('11:00')->format('Ymd\THis'), $response->streamedContent());
141+
$this->assertStringContainsString('LOCATION:The Location', $response->streamedContent());
142+
$this->assertStringContainsString('DESCRIPTION:The description', $response->streamedContent());
143+
$this->assertStringContainsString('URL:https://transformstudios.com', $response->streamedContent());
144+
145+
}
146+
83147
#[Test]
84148
public function can_create_single_day_multiday_event_ics_file()
85149
{

0 commit comments

Comments
 (0)