1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-26 15:54:14 +01:00

Add tests for PHP 8.0

This commit is contained in:
rlanvin 2020-12-09 22:26:35 +01:00
parent 3036bf3df8
commit a14dd53090
4 changed files with 38 additions and 51 deletions

View File

@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4','8.0']
name: PHP ${{ matrix.php }} name: PHP ${{ matrix.php }}
steps: steps:
- name: Checkout - name: Checkout
@ -19,6 +19,11 @@ jobs:
php-version: ${{ matrix.php }} php-version: ${{ matrix.php }}
extensions: intl extensions: intl
- name: Display versions
run: |
php -v
php -i
- name: Cache Composer packages - name: Cache Composer packages
id: composer-cache id: composer-cache
uses: actions/cache@v2 uses: actions/cache@v2
@ -30,10 +35,4 @@ jobs:
if: steps.composer-cache.outputs.cache-hit != 'true' if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install -n run: composer install -n
- name: Display versions
run: |
php -v
php -i
vendor/bin/phpunit -v
- run: vendor/bin/phpunit - run: vendor/bin/phpunit

View File

@ -22,7 +22,7 @@
} }
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7|^6.5", "phpunit/phpunit": "^5.7|^6.5|^8.0",
"phpmd/phpmd" : "@stable" "phpmd/phpmd" : "@stable"
} }
} }

View File

@ -94,10 +94,10 @@ class RRuleTest extends TestCase
/** /**
* @dataProvider invalidRules * @dataProvider invalidRules
* @expectedException InvalidArgumentException
*/ */
public function testInvalidRules($rule) public function testInvalidRules($rule)
{ {
$this->expectException(\InvalidArgumentException::class);
new RRule($rule); new RRule($rule);
} }
@ -1834,12 +1834,10 @@ class RRuleTest extends TestCase
), $rrule->getOccurrences(5)); ), $rrule->getOccurrences(5));
} }
/**
* @expectedException LogicException
* @expectedExceptionMessage Cannot get all occurrences of an infinite recurrence rule.
*/
public function testGetOccurrencesThrowsLogicException() public function testGetOccurrencesThrowsLogicException()
{ {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage("Cannot get all occurrences of an infinite recurrence rule.");
$rrule = new RRule(array( $rrule = new RRule(array(
'FREQ' => 'DAILY', 'FREQ' => 'DAILY',
'DTSTART' => '2017-01-01' 'DTSTART' => '2017-01-01'
@ -1889,12 +1887,10 @@ class RRuleTest extends TestCase
$this->assertEquals($expected, $rrule->getOccurrencesBetween($begin, $end, $limit)); $this->assertEquals($expected, $rrule->getOccurrencesBetween($begin, $end, $limit));
} }
/**
* @expectedException LogicException
* @expectedExceptionMessage Cannot get all occurrences of an infinite recurrence rule.
*/
public function testGetOccurrencesBetweenThrowsLogicException() public function testGetOccurrencesBetweenThrowsLogicException()
{ {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage("Cannot get all occurrences of an infinite recurrence rule.");
$rrule = new RRule(array( $rrule = new RRule(array(
'FREQ' => 'DAILY', 'FREQ' => 'DAILY',
'DTSTART' => '2017-01-01' 'DTSTART' => '2017-01-01'
@ -1987,21 +1983,21 @@ class RRuleTest extends TestCase
public function testGetNthOccurrenceFromInvalidIndex() public function testGetNthOccurrenceFromInvalidIndex()
{ {
$rrule = new RRule(['FREQ' => 'DAILY']); $rrule = new RRule(['FREQ' => 'DAILY']);
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$rrule->getNthOccurrenceFrom(date_create('2017-01-09'), []); $rrule->getNthOccurrenceFrom(date_create('2017-01-09'), []);
} }
public function testGetNthOccurrenceBeforeInvalidIndex() public function testGetNthOccurrenceBeforeInvalidIndex()
{ {
$rrule = new RRule(['FREQ' => 'DAILY']); $rrule = new RRule(['FREQ' => 'DAILY']);
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$rrule->getNthOccurrenceBefore(date_create('2017-01-09'), -1); $rrule->getNthOccurrenceBefore(date_create('2017-01-09'), -1);
} }
public function testGetNthOccurrenceAfterInvalidIndex() public function testGetNthOccurrenceAfterInvalidIndex()
{ {
$rrule = new RRule(['FREQ' => 'DAILY']); $rrule = new RRule(['FREQ' => 'DAILY']);
$this->expectException('InvalidArgumentException'); $this->expectException(\InvalidArgumentException::class);
$rrule->getNthOccurrenceAfter(date_create('2017-01-09'), -1); $rrule->getNthOccurrenceAfter(date_create('2017-01-09'), -1);
} }
@ -2178,12 +2174,11 @@ class RRuleTest extends TestCase
$this->assertEquals('2017-01-01', $rrule[0]->format('Y-m-d')); $this->assertEquals('2017-01-01', $rrule[0]->format('Y-m-d'));
} }
/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Too many DTSTART properties (there can be only one)
*/
public function testRfcStringParserWithMultipleDtStart() public function testRfcStringParserWithMultipleDtStart()
{ {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage("Too many DTSTART properties (there can be only one)");
$rrule = new RRule("DTSTART:19970512\nRRULE:FREQ=YEARLY", date_create('2017-01-01')); $rrule = new RRule("DTSTART:19970512\nRRULE:FREQ=YEARLY", date_create('2017-01-01'));
} }
@ -2214,10 +2209,10 @@ class RRuleTest extends TestCase
/** /**
* @dataProvider quirkyRfcStrings * @dataProvider quirkyRfcStrings
* @expectedException PHPUnit\Framework\Error\Notice
*/ */
public function testQuirkyRfcStringsParserNotice($str,$occurrences) public function testQuirkyRfcStringsParserNotice($str,$occurrences)
{ {
$this->expectException(\PHPUnit\Framework\Error\Notice::class);
$rule = new RRule($str); $rule = new RRule($str);
} }
@ -2283,11 +2278,11 @@ class RRuleTest extends TestCase
} }
/** /**
* @expectedException InvalidArgumentException
* @dataProvider invalidRfcStrings * @dataProvider invalidRfcStrings
*/ */
public function testInvalidRfcStrings($str) public function testInvalidRfcStrings($str)
{ {
$this->expectException(\InvalidArgumentException::class);
$rule = new RRule($str); $rule = new RRule($str);
} }
@ -2801,7 +2796,7 @@ class RRuleTest extends TestCase
$rrule = new RRule(array( $rrule = new RRule(array(
'freq' => 'yearly' 'freq' => 'yearly'
)); ));
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
count($rrule); count($rrule);
} }
@ -2845,7 +2840,7 @@ class RRuleTest extends TestCase
'byday' => 'TU,TH', 'byday' => 'TU,TH',
'dtstart' => '2007-01-01' 'dtstart' => '2007-01-01'
)); ));
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
$rrule[] = 'blah'; $rrule[] = 'blah';
} }
@ -2857,7 +2852,7 @@ class RRuleTest extends TestCase
'byday' => 'TU,TH', 'byday' => 'TU,TH',
'dtstart' => '2007-01-01' 'dtstart' => '2007-01-01'
)); ));
$this->expectException('LogicException'); $this->expectException(\LogicException::class);
unset($rrule[0]); unset($rrule[0]);
} }
@ -2876,10 +2871,10 @@ class RRuleTest extends TestCase
/** /**
* @dataProvider illegalOffsets * @dataProvider illegalOffsets
* @expectedException InvalidArgumentException
*/ */
public function testOffsetGetInvalidArgument($offset) public function testOffsetGetInvalidArgument($offset)
{ {
$this->expectException(\InvalidArgumentException::class);
$rrule = new RRule(array( $rrule = new RRule(array(
'freq' => 'daily', 'freq' => 'daily',
'count' => 3, 'count' => 3,
@ -3014,11 +3009,10 @@ class RRuleTest extends TestCase
/** /**
* Tests that the RRule::i18nLoad() fails as expected on invalid $locale settings * Tests that the RRule::i18nLoad() fails as expected on invalid $locale settings
*
* @expectedException \InvalidArgumentException
*/ */
public function testI18nLoadFailsWithoutIntl() public function testI18nLoadFailsWithoutIntl()
{ {
$this->expectException(\InvalidArgumentException::class);
$reflector = new ReflectionClass('RRule\RRule'); $reflector = new ReflectionClass('RRule\RRule');
$method = $reflector->getMethod('i18nLoad'); $method = $reflector->getMethod('i18nLoad');
@ -3028,11 +3022,10 @@ class RRuleTest extends TestCase
/** /**
* Tests that the RRule::i18nLoad() fails as expected on invalid $fallback settings * Tests that the RRule::i18nLoad() fails as expected on invalid $fallback settings
*
* @expectedException \InvalidArgumentException
*/ */
public function testI18nLoadFallbackFailsWitoutIntl() public function testI18nLoadFallbackFailsWitoutIntl()
{ {
$this->expectException(\InvalidArgumentException::class);
$reflector = new ReflectionClass('RRule\RRule'); $reflector = new ReflectionClass('RRule\RRule');
$method = $reflector->getMethod('i18nLoad'); $method = $reflector->getMethod('i18nLoad');
@ -3040,11 +3033,9 @@ class RRuleTest extends TestCase
$method->invokeArgs(null, array('xx', 'invalid', false)); $method->invokeArgs(null, array('xx', 'invalid', false));
} }
/**
* @expectedException RuntimeException
*/
public function testHumanReadableRuntimeException() public function testHumanReadableRuntimeException()
{ {
$this->expectException(\RuntimeException::class);
$rrule = new RRule(array( $rrule = new RRule(array(
'freq' => 'daily', 'freq' => 'daily',
'count' => 10, 'count' => 10,

View File

@ -425,10 +425,10 @@ class RSetTest extends TestCase
/** /**
* @dataProvider illegalOffsets * @dataProvider illegalOffsets
* @expectedException InvalidArgumentException
*/ */
public function testOffsetGetInvalidArgument($offset) public function testOffsetGetInvalidArgument($offset)
{ {
$this->expectException(\InvalidArgumentException::class);
$rset = new RSet(); $rset = new RSet();
$rset->addRRule(array( $rset->addRRule(array(
'FREQ' => 'YEARLY', 'FREQ' => 'YEARLY',
@ -621,12 +621,10 @@ class RSetTest extends TestCase
), $rset->getOccurrences(5)); ), $rset->getOccurrences(5));
} }
/**
* @expectedException LogicException
* @expectedExceptionMessage Cannot get all occurrences of an infinite recurrence set.
*/
public function testGetOccurrencesThrowsLogicException() public function testGetOccurrencesThrowsLogicException()
{ {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage("Cannot get all occurrences of an infinite recurrence set.");
$rset = new RSet(); $rset = new RSet();
$rset->addRRule(new RRule(array( $rset->addRRule(new RRule(array(
'FREQ' => 'DAILY', 'FREQ' => 'DAILY',
@ -664,12 +662,12 @@ class RSetTest extends TestCase
$this->assertEquals($expected, $rset->getOccurrencesBetween($begin, $end, $limit)); $this->assertEquals($expected, $rset->getOccurrencesBetween($begin, $end, $limit));
} }
/**
* @expectedException LogicException
* @expectedExceptionMessage Cannot get all occurrences of an infinite recurrence rule.
*/
public function testGetOccurrencesBetweenThrowsLogicException() public function testGetOccurrencesBetweenThrowsLogicException()
{ {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage("Cannot get all occurrences of an infinite recurrence rule.");
$rset = new RSet(); $rset = new RSet();
$rset->addRRule(new RRule(array( $rset->addRRule(new RRule(array(
'FREQ' => 'DAILY', 'FREQ' => 'DAILY',
@ -828,12 +826,10 @@ class RSetTest extends TestCase
), $rset->getOccurrences()); ), $rset->getOccurrences());
} }
/**
* @expectedException InvalidArgumentException
* @expectedExcpetionMessage Failed to parse RFC string, multiple DTSTART found
*/
public function testParseRfcStringWithMultipleDtStart() public function testParseRfcStringWithMultipleDtStart()
{ {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage("Failed to parse RFC string, multiple DTSTART found");
$rset = new RSet( $rset = new RSet(
"DTSTART:DTSTART;TZID=America/New_York:19970901T090000\nRRULE:FREQ=DAILY;COUNT=3\nEXRULE:FREQ=DAILY;INTERVAL=2;COUNT=1", "DTSTART:DTSTART;TZID=America/New_York:19970901T090000\nRRULE:FREQ=DAILY;COUNT=3\nEXRULE:FREQ=DAILY;INTERVAL=2;COUNT=1",
date_create('2017-01-01') date_create('2017-01-01')
@ -859,10 +855,11 @@ class RSetTest extends TestCase
/** /**
* @dataProvider quirkyRfcStrings * @dataProvider quirkyRfcStrings
* @expectedException PHPUnit\Framework\Error\Notice
*/ */
public function testParseQuirkyRfcStringNotice($string, $occurrences) public function testParseQuirkyRfcStringNotice($string, $occurrences)
{ {
$this->expectException(\PHPUnit\Framework\Error\Notice::class);
$object = new RSet($string); $object = new RSet($string);
} }