Skip to content

Commit 091a161

Browse files
authored
Merge pull request #664 from jarikmarwede/master
Fix VTODO validation for PERCENT-COMPLETE
2 parents 1b388aa + 4f21237 commit 091a161

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/Component/VTodo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getValidationRules(): array
104104
'LAST-MODIFIED' => '?',
105105
'LOCATION' => '?',
106106
'ORGANIZER' => '?',
107-
'PERCENT' => '?',
107+
'PERCENT-COMPLETE' => '?',
108108
'PRIORITY' => '?',
109109
'RECURRENCE-ID' => '?',
110110
'SEQUENCE' => '?',

tests/VObject/Component/VTodoTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,31 @@ public function testValidateDueBeforeDateTimeStart(): void
168168
'DUE must occur after DTSTART',
169169
], $messages);
170170
}
171+
172+
public function testValidateDuplicatePercentComplete(): void
173+
{
174+
$input = <<<HI
175+
BEGIN:VCALENDAR
176+
VERSION:2.0
177+
PRODID:YoYo
178+
BEGIN:VTODO
179+
UID:8ed267e1-67c4-467d-8ae2-28e6ff03b033
180+
DTSTAMP:20240729T133309Z
181+
PERCENT-COMPLETE:70
182+
PERCENT-COMPLETE:80
183+
END:VTODO
184+
END:VCALENDAR
185+
HI;
186+
$obj = Reader::read($input);
187+
188+
$warnings = $obj->validate();
189+
$messages = [];
190+
foreach ($warnings as $warning) {
191+
$messages[] = $warning['message'];
192+
}
193+
194+
self::assertEquals([
195+
'PERCENT-COMPLETE MUST NOT appear more than once in a VTODO component',
196+
], $messages);
197+
}
171198
}

0 commit comments

Comments
 (0)