mirror of
https://github.com/simshaun/recurr.git
synced 2025-01-16 23:48:13 +01:00
Merge pull request #190 from ankurk91/feat/php-8-support
Test on php 8 - use github actions
This commit is contained in:
commit
b5aa5b07a5
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,3 +1,3 @@
|
||||
/.github export-ignore
|
||||
/tests export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
|
38
.github/workflows/tests.yml
vendored
Normal file
38
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
name: tests
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 0 15 * *'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: [7.2, 7.3, 7.4, 8.0]
|
||||
|
||||
name: php v${{ matrix.php }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo
|
||||
tools: composer:v2
|
||||
coverage: pcov
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-interaction --no-progress
|
||||
|
||||
- name: Execute tests
|
||||
run: composer test
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/vendor/
|
||||
/.idea/
|
||||
/composer.lock
|
||||
/.phpunit.result.cache
|
20
.travis.yml
20
.travis.yml
@ -1,20 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
- 8.0
|
||||
env:
|
||||
global:
|
||||
- XDEBUG_MODE=coverage
|
||||
install:
|
||||
- composer self-update
|
||||
- composer update
|
||||
- composer --prefer-source install
|
||||
script: ./vendor/bin/phpunit --coverage-text
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
14
README.md
14
README.md
@ -1,4 +1,10 @@
|
||||
# Recurr [![Build Status](https://travis-ci.org/simshaun/recurr.png)](https://travis-ci.org/simshaun/recurr.png) [![Latest Stable Version](https://poser.pugx.org/simshaun/recurr/v/stable.svg)](https://packagist.org/packages/simshaun/recurr) [![Total Downloads](https://poser.pugx.org/simshaun/recurr/downloads.svg)](https://packagist.org/packages/simshaun/recurr) [![Latest Unstable Version](https://poser.pugx.org/simshaun/recurr/v/unstable.svg)](https://packagist.org/packages/simshaun/recurr) [![License](https://poser.pugx.org/simshaun/recurr/license.svg)](https://packagist.org/packages/simshaun/recurr)
|
||||
# Recurr
|
||||
|
||||
[![tests](https://github.com/simshaun/recurr/workflows/tests/badge.svg)](https://github.com/simshaun/recurr/actions)
|
||||
[![Latest Stable Version](https://poser.pugx.org/simshaun/recurr/v/stable.svg)](https://packagist.org/packages/simshaun/recurr)
|
||||
[![Total Downloads](https://poser.pugx.org/simshaun/recurr/downloads.svg)](https://packagist.org/packages/simshaun/recurr)
|
||||
[![Latest Unstable Version](https://poser.pugx.org/simshaun/recurr/v/unstable.svg)](https://packagist.org/packages/simshaun/recurr)
|
||||
[![License](https://poser.pugx.org/simshaun/recurr/license.svg)](https://packagist.org/packages/simshaun/recurr)
|
||||
|
||||
Recurr is a PHP library for working with recurrence rules ([RRULE](https://tools.ietf.org/html/rfc5545)) and converting them in to DateTime objects.
|
||||
|
||||
@ -9,7 +15,9 @@ Installing Recurr
|
||||
|
||||
The recommended way to install Recurr is through [Composer](http://getcomposer.org).
|
||||
|
||||
`composer require simshaun/recurr`
|
||||
```bash
|
||||
composer require simshaun/recurr
|
||||
```
|
||||
|
||||
Using Recurr
|
||||
-----------
|
||||
@ -153,4 +161,4 @@ Feel free to comment or make pull requests. Please include tests with PRs.
|
||||
License
|
||||
-------
|
||||
|
||||
Recurr is licensed under the MIT License. See the LICENSE file for details.
|
||||
Recurr is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
|
||||
|
@ -13,11 +13,12 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"doctrine/collections": "~1.3"
|
||||
"php": "^7.2||^8.0",
|
||||
"doctrine/collections": "~1.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~5.7"
|
||||
"phpunit/phpunit": "^8.5.16",
|
||||
"symfony/yaml": "^5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@ -33,5 +34,8 @@
|
||||
"branch-alias": {
|
||||
"dev-master": "0.x-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./vendor/bin/phpunit --color=always"
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="./tests/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd">
|
||||
<testsuites>
|
||||
<testsuite name="Recurr Test Suite">
|
||||
<directory suffix="Test.php">./tests/Recurr/Test/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="Recurr Test Suite">
|
||||
<directory suffix="Test.php">./tests/Recurr/Test/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src/Recurr/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src/Recurr/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
@ -5,12 +5,12 @@ namespace Recurr\Test;
|
||||
use Recurr\Recurrence;
|
||||
use Recurr\RecurrenceCollection;
|
||||
|
||||
class RecurrenceCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
class RecurrenceCollectionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var RecurrenceCollection */
|
||||
protected $collection;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->collection = new RecurrenceCollection(
|
||||
array(
|
||||
|
@ -7,12 +7,12 @@ use Recurr\DateInclusion;
|
||||
use Recurr\Frequency;
|
||||
use Recurr\Rule;
|
||||
|
||||
class RuleTest extends \PHPUnit_Framework_TestCase
|
||||
class RuleTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var Rule */
|
||||
protected $rule;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->rule = new Rule;
|
||||
}
|
||||
@ -51,19 +51,15 @@ class RuleTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($startDate->getTimezone()->getName(), $this->rule->getTimezone());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidRRule
|
||||
*/
|
||||
public function testLoadFromStringWithMissingFreq()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidRRule::class);
|
||||
$this->rule->loadFromString('COUNT=2');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidRRule
|
||||
*/
|
||||
public function testLoadFromStringWithBothCountAndUntil()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidRRule::class);
|
||||
$this->rule->loadFromString('FREQ=DAILY;COUNT=2;UNTIL=20130510');
|
||||
}
|
||||
|
||||
@ -312,11 +308,9 @@ class RuleTest extends \PHPUnit_Framework_TestCase
|
||||
date_default_timezone_set($defaultTimezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidRRule
|
||||
*/
|
||||
public function testLoadFromStringFails()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidRRule::class);
|
||||
$this->rule->loadFromString('IM AN INVALID RRULE');
|
||||
}
|
||||
|
||||
@ -403,7 +397,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->rule->loadFromString($string);
|
||||
|
||||
$this->assertNotContains('WKST', $this->rule->getString());
|
||||
$this->assertStringNotContainsString('WKST', $this->rule->getString());
|
||||
}
|
||||
|
||||
public function testGetStringWithExplicitWkst()
|
||||
@ -412,7 +406,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->rule->loadFromString($string);
|
||||
|
||||
$this->assertContains('WKST=TH', $this->rule->getString());
|
||||
$this->assertStringContainsString('WKST=TH', $this->rule->getString());
|
||||
}
|
||||
|
||||
public function testSetStartDateAffectsStringOutput()
|
||||
@ -430,35 +424,27 @@ class RuleTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('FREQ=MONTHLY;COUNT=2', $this->rule->getString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidArgument
|
||||
*/
|
||||
public function testBadInterval()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidArgument::class);
|
||||
$this->rule->setInterval('six');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidRRule
|
||||
*/
|
||||
public function testEmptyByDayThrowsException()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidRRule::class);
|
||||
$this->rule->setByDay(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidRRule
|
||||
*/
|
||||
public function testEmptyByDayFromStringThrowsException()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidRRule::class);
|
||||
$this->rule->loadFromString('FREQ=WEEKLY;BYDAY=;INTERVAL=1;UNTIL=20160725');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Recurr\Exception\InvalidArgument
|
||||
*/
|
||||
public function testBadWeekStart()
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidArgument::class);
|
||||
$this->rule->setWeekStart('monday');
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,14 @@ namespace Recurr\Test\Transformer;
|
||||
|
||||
use Recurr\Transformer\ArrayTransformer;
|
||||
|
||||
class ArrayTransformerBase extends \PHPUnit_Framework_TestCase
|
||||
class ArrayTransformerBase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var ArrayTransformer */
|
||||
protected $transformer;
|
||||
|
||||
protected $timezone = 'America/New_York';
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->transformer = new ArrayTransformer();
|
||||
}
|
||||
|
@ -97,10 +97,10 @@ class ArrayTransformerByDayTest extends ArrayTransformerBase
|
||||
|
||||
/**
|
||||
* @dataProvider unsupportedNthByDayFrequencies
|
||||
* @expectedException \Recurr\Exception\InvalidRRule
|
||||
*/
|
||||
public function testNthByDayWithUnsupportedFrequency($frequency)
|
||||
{
|
||||
$this->expectException(\Recurr\Exception\InvalidRRule::class);
|
||||
new Rule(
|
||||
"FREQ=$frequency;COUNT=3;BYDAY=2MO",
|
||||
new \DateTime('1997-05-19 16:00:00')
|
||||
|
@ -15,7 +15,7 @@ class ArrayTransformerExDateTest extends ArrayTransformerBase
|
||||
*/
|
||||
protected static $originalTimezoneName;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$originalTimezoneName = date_default_timezone_get();
|
||||
date_default_timezone_set('America/New_York');
|
||||
@ -23,7 +23,7 @@ class ArrayTransformerExDateTest extends ArrayTransformerBase
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
date_default_timezone_set(self::$originalTimezoneName);
|
||||
|
||||
|
@ -15,7 +15,7 @@ class ArrayTransformerRDateTest extends ArrayTransformerBase
|
||||
*/
|
||||
protected static $originalTimezoneName;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$originalTimezoneName = date_default_timezone_get();
|
||||
date_default_timezone_set('America/New_York');
|
||||
@ -23,7 +23,7 @@ class ArrayTransformerRDateTest extends ArrayTransformerBase
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
date_default_timezone_set(self::$originalTimezoneName);
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace Recurr\Test\Transformer\Filter;
|
||||
|
||||
use Recurr\Transformer\Constraint\AfterConstraint;
|
||||
|
||||
class AfterConstraintTest extends \PHPUnit_Framework_TestCase
|
||||
class AfterConstraintTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testAfter()
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace Recurr\Test\Transformer\Filter;
|
||||
|
||||
use Recurr\Transformer\Constraint\BeforeConstraint;
|
||||
|
||||
class BeforeConstraintTest extends \PHPUnit_Framework_TestCase
|
||||
class BeforeConstraintTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testBefore()
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace Recurr\Test\Transformer\Filter;
|
||||
|
||||
use Recurr\Transformer\Constraint\BetweenConstraint;
|
||||
|
||||
class BetweenConstraintTest extends \PHPUnit_Framework_TestCase
|
||||
class BetweenConstraintTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testBetween()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ use Symfony\Component\Yaml\Yaml;
|
||||
use Recurr\Transformer\Translator;
|
||||
use Recurr\Transformer\TextTransformer;
|
||||
|
||||
class TextTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
class TextTransformerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private static $languages = array();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user