Skip to content

Commit

Permalink
Add test on BYMONTHDAY
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbonneaud committed Jan 30, 2020
1 parent 647533a commit 1deaef6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions lib/Recur/RRuleIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,11 @@ protected function parseRRule($rrule)

case 'BYMONTHDAY':
$this->byMonthDay = (array) $value;
foreach ($this->byMonthDay as $byMonthDay) {
if (!is_numeric($byMonthDay) || (int) $byMonthDay < -31 || 0 == (int) $byMonthDay || (int) $byMonthDay > 31) {
throw new InvalidDataException('BYMONTHDAY in RRULE must have value(s) from 1 to 31, or -31 to -1!');
}
}
break;

case 'BYYEARDAY':
Expand Down
30 changes: 20 additions & 10 deletions tests/VObject/Recur/RRuleIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@

class RRuleIteratorTest extends TestCase
{
public function testInvalidMissingFreq()
{
$this->expectException(InvalidDataException::class);
$this->parse(
'COUNT=6;BYMONTHDAY=24;BYMONTH=1',
'2011-04-07 00:00:00',
[]
);
}

public function testHourly()
{
$this->parse(
Expand Down Expand Up @@ -316,6 +306,16 @@ public function testMonthlyByMonthDay()
);
}

public function testInvalidByMonthDay()
{
$this->expectException(InvalidDataException::class);
$this->parse(
'FREQ=MONTHLY;COUNT=6;BYMONTHDAY=1,5,10,42',
'2011-04-07 00:00:00',
[]
);
}

public function testMonthlyByDay()
{
$this->parse(
Expand Down Expand Up @@ -895,6 +895,16 @@ public function testInvalidFreq()
);
}

public function testInvalidMissingFreq()
{
$this->expectException(InvalidDataException::class);
$this->parse(
'COUNT=6;BYMONTHDAY=24;BYMONTH=1',
'2011-04-07 00:00:00',
[]
);
}

/**
* @expectedException \Sabre\VObject\InvalidDataException
*/
Expand Down

0 comments on commit 1deaef6

Please sign in to comment.