Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VTODO validation for PERCENT-COMPLETE #664

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Component/VTodo.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function getValidationRules(): array
'LAST-MODIFIED' => '?',
'LOCATION' => '?',
'ORGANIZER' => '?',
'PERCENT' => '?',
'PERCENT-COMPLETE' => '?',
'PRIORITY' => '?',
'RECURRENCE-ID' => '?',
'SEQUENCE' => '?',
Expand Down
27 changes: 27 additions & 0 deletions tests/VObject/Component/VTodoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,31 @@ public function testValidateDueBeforeDateTimeStart(): void
'DUE must occur after DTSTART',
], $messages);
}

public function testValidateDuplicatePercentComplete(): void
{
$input = <<<HI
BEGIN:VCALENDAR
VERSION:2.0
PRODID:YoYo
BEGIN:VTODO
UID:8ed267e1-67c4-467d-8ae2-28e6ff03b033
DTSTAMP:20240729T133309Z
PERCENT-COMPLETE:70
PERCENT-COMPLETE:80
END:VTODO
END:VCALENDAR
HI;
$obj = Reader::read($input);

$warnings = $obj->validate();
$messages = [];
foreach ($warnings as $warning) {
$messages[] = $warning['message'];
}

self::assertEquals([
'PERCENT-COMPLETE MUST NOT appear more than once in a VTODO component',
], $messages);
}
}