Skip to content

Commit 318da69

Browse files
committed
Fixed unit tests
Signed-off-by: Mua N. Laurent <[email protected]>
1 parent 808837c commit 318da69

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

src/DataTypes/Calendar.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,18 @@ protected function buildCalendarString()
106106
if (isset($this->summary)) {
107107
$calendar .= "SUMMARY:".$this->summary.$this->separator;
108108
}
109-
if (isset($this->location)) {
110-
$calendar .= "LOCATION:".$this->location.$this->separator;
111-
}
112-
if (isset($this->url)) {
113-
$calendar .= "URL:".$this->url.$this->separator;
114-
}
115109
if (isset($this->startDateTime)) {
116110
$calendar .= "DTSTART:".$this->startDateTime.$this->separator;
117111
}
118112
if (isset($this->endDateTime)) {
119113
$calendar .= "DTEND:".$this->endDateTime.$this->separator;
120114
}
115+
if (isset($this->location)) {
116+
$calendar .= "LOCATION:".$this->location.$this->separator;
117+
}
118+
if (isset($this->url)) {
119+
$calendar .= "URL:".$this->url.$this->separator;
120+
}
121121

122122
$calendar .= $this->suffix;
123123

@@ -145,15 +145,15 @@ protected function setProperties(array $arguments)
145145
$this->summary = $arguments['summary'];
146146
$this->setEventDateTime($arguments['startDateTime'], "start");
147147

148+
if (isset($arguments['endDateTime'])) {
149+
$this->setEventDateTime($arguments['endDateTime'], "end");
150+
}
148151
if (isset($arguments['location'])) {
149152
$this->location = $arguments['location'];
150153
}
151154
if (isset($arguments['url'])) {
152155
$this->setUrl($arguments['url']);
153156
}
154-
if (isset($arguments['endDateTime'])) {
155-
$this->setEventDateTime($arguments['endDateTime'], "end");
156-
}
157157
}
158158
}
159159

tests/DataTypes/CalendarTest.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ public function test_it_generates_a_proper_format_with_summary_start_date_time_a
127127
0 => [
128128
'summary' => 'My FooBar Event',
129129
'startDateTime' => '2020-10-08 16:00',
130-
'location' => 'Foo Location'
130+
'location' => 'Fooon'
131131
],
132132
]);
133133

134134
$properFormat = "BEGIN:VEVENT".$this->separator.
135135
"SUMMARY:My FooBar Event".$this->separator.
136136
"DTSTART:20201008UTC161000".$this->separator.
137-
"LOCATION:Foo Location".$this->separator.
137+
"LOCATION:Fooon".$this->separator.
138138
"END:VEVENT";
139139

140140
$this->assertEquals($properFormat, strval($this->calendar));
@@ -159,4 +159,28 @@ public function test_it_generates_a_proper_format_with_summary_start_date_time_a
159159
$this->assertEquals($properFormat, strval($this->calendar));
160160
}
161161

162+
public function test_it_generates_a_proper_format_with_calendar_parameters()
163+
{
164+
$this->calendar->create([
165+
0 => [
166+
'summary' => 'My FooBar Event',
167+
'startDateTime' => '2020-10-08 16:00',
168+
'endDateTime' => '2020-10-08 18:00',
169+
'location' => 'Foo Location',
170+
'url' => 'https://www.google.com',
171+
'dateTimeFormat' => 'Y-m-d H:i'
172+
],
173+
]);
174+
175+
$properFormat = "BEGIN:VEVENT".$this->separator.
176+
"SUMMARY:My FooBar Event".$this->separator.
177+
"DTSTART:20201008UTC161000".$this->separator.
178+
"DTEND:20201008UTC181000".$this->separator.
179+
"LOCATION:Foo Location".$this->separator.
180+
"URL:https://www.google.com".$this->separator.
181+
"END:VEVENT";
182+
183+
$this->assertEquals($properFormat, strval($this->calendar));
184+
}
185+
162186
}

0 commit comments

Comments
 (0)