Skip to content

Commit

Permalink
Merge pull request simshaun#190 from ankurk91/feat/php-8-support
Browse files Browse the repository at this point in the history
Test on php 8 - use github actions
  • Loading branch information
simshaun authored Sep 9, 2021
2 parents c4ad46a + efd7388 commit b5aa5b0
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/.github export-ignore
/tests export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
/.idea/
/composer.lock
/.phpunit.result.cache
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
-----------
Expand Down Expand Up @@ -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.
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -33,5 +34,8 @@
"branch-alias": {
"dev-master": "0.x-dev"
}
},
"scripts": {
"test": "./vendor/bin/phpunit --color=always"
}
}
33 changes: 21 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 2 additions & 2 deletions tests/Recurr/Test/RecurrenceCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
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(
Expand Down
36 changes: 11 additions & 25 deletions tests/Recurr/Test/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
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;
}
Expand Down Expand Up @@ -51,19 +51,15 @@ public function testTimezoneObtainedFromStartDate()
$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');
}

Expand Down Expand Up @@ -312,11 +308,9 @@ public function testLoadFromStringWithDtend()
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');
}

Expand Down Expand Up @@ -403,7 +397,7 @@ public function testGetStringWithoutExplicitWkst()

$this->rule->loadFromString($string);

$this->assertNotContains('WKST', $this->rule->getString());
$this->assertStringNotContainsString('WKST', $this->rule->getString());
}

public function testGetStringWithExplicitWkst()
Expand All @@ -412,7 +406,7 @@ public function testGetStringWithExplicitWkst()

$this->rule->loadFromString($string);

$this->assertContains('WKST=TH', $this->rule->getString());
$this->assertStringContainsString('WKST=TH', $this->rule->getString());
}

public function testSetStartDateAffectsStringOutput()
Expand All @@ -430,35 +424,27 @@ public function testSetStartDateAffectsStringOutput()
$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');
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Recurr/Test/Transformer/ArrayTransformerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public function testByDayYearly()

/**
* @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')
Expand Down
4 changes: 2 additions & 2 deletions tests/Recurr/Test/Transformer/ArrayTransformerExDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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');

parent::setUpBeforeClass();
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
date_default_timezone_set(self::$originalTimezoneName);

Expand Down
4 changes: 2 additions & 2 deletions tests/Recurr/Test/Transformer/ArrayTransformerRDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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');

parent::setUpBeforeClass();
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
date_default_timezone_set(self::$originalTimezoneName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Recurr\Transformer\Constraint\AfterConstraint;

class AfterConstraintTest extends \PHPUnit_Framework_TestCase
class AfterConstraintTest extends \PHPUnit\Framework\TestCase
{
public function testAfter()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Recurr\Transformer\Constraint\BeforeConstraint;

class BeforeConstraintTest extends \PHPUnit_Framework_TestCase
class BeforeConstraintTest extends \PHPUnit\Framework\TestCase
{
public function testBefore()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Recurr\Transformer\Constraint\BetweenConstraint;

class BetweenConstraintTest extends \PHPUnit_Framework_TestCase
class BetweenConstraintTest extends \PHPUnit\Framework\TestCase
{
public function testBetween()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Recurr/Test/Transformer/TextTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Recurr\Transformer\Translator;
use Recurr\Transformer\TextTransformer;

class TextTransformerTest extends \PHPUnit_Framework_TestCase
class TextTransformerTest extends \PHPUnit\Framework\TestCase
{
private static $languages = array();

Expand Down

0 comments on commit b5aa5b0

Please sign in to comment.