1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2024-11-28 05:24:10 +01:00

Fix typos and update CHANGELOG for 2.2.2

This commit is contained in:
rlanvin 2021-01-09 14:18:28 +01:00
parent cf4fc8e827
commit 63b55000b4
4 changed files with 32 additions and 13 deletions

View File

@ -2,6 +2,12 @@
## [Unreleased]
## [2.2.2] - 2021-01-09
### Fixed
- Fix `getOccurrencesAfter` returns empty array when `$inclusive` is `false` and `$limit` is not set [#93](https://github.com/rlanvin/php-rrule/pull/93)
## [2.2.1] - 2020-12-09
### Fixed
@ -196,7 +202,8 @@
- First release, everything before that was unversioned (`dev-master` was used).
[Unreleased]: https://github.com/rlanvin/php-rrule/compare/v2.2.1...HEAD
[Unreleased]: https://github.com/rlanvin/php-rrule/compare/v2.2.2...HEAD
[2.2.2]: https://github.com/rlanvin/php-rrule/compare/v2.2.1...v2.2.2
[2.2.1]: https://github.com/rlanvin/php-rrule/compare/v2.2.0...v2.2.1
[2.2.0]: https://github.com/rlanvin/php-rrule/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/rlanvin/php-rrule/compare/v2.0.0...v2.1.0

View File

@ -1314,7 +1314,7 @@ class RRule implements RRuleInterface
* at year 1 to Jan 1st 10.00 at year 2.
*
* In order to make a "smart jump", we would have to have a way to determine
* the gap between the next occurence arithmetically. I think that would require
* the gap between the next occurrence arithmetically. I think that would require
* to analyze each "BYXXX" rule part that "Limit" the set (see the RFC page 43)
* at the given frequency. For example, a YEARLY frequency doesn't need "smart
* jump" at all; MONTHLY and WEEKLY frequencies only need to check BYMONTH;

View File

@ -99,7 +99,7 @@ trait RRuleTrait
return $res;
}
public function getOccurrencesAfter($date, $inclusive = false, $limit = null)
public function getOccurrencesAfter($date, $inclusive = false, $limit = null)
{
if ($inclusive || ! $this->occursAt($date)) {
return $this->getOccurrencesBetween($date, null, $limit);

View File

@ -1253,7 +1253,7 @@ class RRuleTest extends TestCase
date_create('1999-03-11 09:00:00'),
date_create('1999-03-12 09:00:00'),
date_create('1999-03-13 09:00:00'))),
// Every Tuesday, every other month, 6 occurences.
// Every Tuesday, every other month, 6 occurrences.
array(
array('freq' => 'monthly', 'count' => 6, 'interval' => 2, 'byday' => 'TU', 'dtstart' => '1997-09-02 09:00:00'),
array(date_create('1997-09-02 09:00:00'),
@ -1501,7 +1501,7 @@ class RRuleTest extends TestCase
}
/**
* Rules that generate no occurence, because of a bad combination of BYXXX parts
* Rules that generate no occurrence, because of a bad combination of BYXXX parts
* This tests are here to ensure that the lib will not go into an infinite loop.
*/
public function rulesWithoutOccurrences()
@ -1525,7 +1525,7 @@ class RRuleTest extends TestCase
'count' => 1
)),
// haven't found a weekly rule with no occurence yet
// haven't found a weekly rule with no occurrence yet
// every 7 days, monday, starting a wednesday (still nope)
array(array(
@ -1785,10 +1785,10 @@ class RRuleTest extends TestCase
/**
* @dataProvider notOccurrences
*/
public function testNotOccurrences($rule, $not_occurences)
public function testNotOccurrences($rule, $not_occurrences)
{
$rule = new RRule($rule);
foreach ($not_occurences as $date) {
foreach ($not_occurrences as $date) {
$this->assertFalse($rule->occursAt($date), "Rule must not match $date");
}
}
@ -1912,6 +1912,7 @@ class RRuleTest extends TestCase
{
return [
["DTSTART:20170101\nRRULE:FREQ=DAILY;UNTIL=20170103", '2017-01-01', false, null, [date_create('2017-01-02'), date_create('2017-01-03')]],
["DTSTART:20170101\nRRULE:FREQ=DAILY;UNTIL=20170103", '2017-01-01', true, null, [date_create('2017-01-01'), date_create('2017-01-02'), date_create('2017-01-03')]],
["DTSTART:20170101\nRRULE:FREQ=DAILY", '2017-02-01', false, 2, [date_create('2017-02-02'),date_create('2017-02-03')]],
["DTSTART:20170101\nRRULE:FREQ=DAILY", '2017-02-01', true, 2, [date_create('2017-02-01'),date_create('2017-02-02')]],
["DTSTART:20170101\nRRULE:FREQ=DAILY;INTERVAL=2", '2017-01-02', true, 2, [date_create('2017-01-03'),date_create('2017-01-05')]],
@ -1929,6 +1930,17 @@ class RRuleTest extends TestCase
$this->assertEquals($expected, $occurrences);
}
public function testGetOccurrencesAfterThrowsLogicException()
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage("Cannot get all occurrences of an infinite recurrence rule.");
$rrule = new RRule(array(
'FREQ' => 'DAILY',
'DTSTART' => '2017-01-01'
));
$rrule->getOccurrencesAfter('2017-01-01');
}
public function occurrencesBefore()
{
return [
@ -2730,31 +2742,31 @@ class RRuleTest extends TestCase
$occurrence->modify('+1 day');
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with foreach (cached)');
// getOccurences
// getOccurrences
$occurrences = $rrule->getOccurrences();
$this->assertEquals(date_create('2007-01-01'), $occurrences[0]);
$occurrences[0]->modify('+1 day');
$this->assertEquals(date_create('2007-01-02'), $occurrences[0]);
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurences (uncached version)');
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurrences (uncached version)');
$occurrences = $rrule->getOccurrences();
$this->assertEquals(date_create('2007-01-01'), $occurrences[0]);
$occurrences[0]->modify('+1 day');
$this->assertEquals(date_create('2007-01-02'), $occurrences[0]);
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurences (cached version)');
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurrences (cached version)');
// getOccurrencesBetween
$occurrences = $rrule->getOccurrencesBetween(null, null);
$this->assertEquals(date_create('2007-01-01'), $occurrences[0]);
$occurrences[0]->modify('+1 day');
$this->assertEquals(date_create('2007-01-02'), $occurrences[0]);
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurences (uncached version)');
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurrences (uncached version)');
$occurrences = $rrule->getOccurrencesBetween(null, null);
$this->assertEquals(date_create('2007-01-01'), $occurrences[0]);
$occurrences[0]->modify('+1 day');
$this->assertEquals(date_create('2007-01-02'), $occurrences[0]);
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurences (cached version)');
$this->assertEquals(date_create('2007-01-01'), $rrule[0], 'No modification possible with getOccurrences (cached version)');
}
public function testGetRule()