Skip to content

Commit

Permalink
Validate count and until property (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Ren Xie Liu <liurx41@protonmail.com>
  • Loading branch information
liurxliu and Ren Xie Liu authored Jan 18, 2021
1 parent 6507b3d commit bee705a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Recur/RRuleIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,10 @@ protected function parseRRule($rrule)
if (!isset($this->frequency)) {
throw new InvalidDataException('Unknown value for FREQ');
}

if (isset($this->count) && isset($this->until)) {
throw new InvalidDataException('Can not have both UNTIL and COUNT property at the same time');
}
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/VObject/Recur/RRuleIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,18 @@ public function testUntilBeforeDtStart()
);
}

public function testUntilAndCount()
{
$this->expectException(InvalidDataException::class);
$this->expectExceptionMessage('Can not have both UNTIL and COUNT property at the same time');

$this->parse(
'FREQ=DAILY;COUNT=5;UNTIL=20201108T225959Z',
'2021-01-18 00:15:00',
[]
);
}

public function testIgnoredStuff()
{
$this->parse(
Expand Down

0 comments on commit bee705a

Please sign in to comment.