Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHP 8 #128

Merged
merged 4 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@ name: Tests
on: [push, pull_request]

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.1', '7.2', '7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
stability: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }} Test

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom
coverage: xdebug
tools: composer
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, dom
coverage: xdebug
tools: composer:v2

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: cache-php-${{ matrix.php-versions }}-composer-${{ hashFiles('composer.json') }}
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Run test suite
run: |
composer install
composer test
- name: Run test suite
run: composer test
65 changes: 32 additions & 33 deletions .github/workflows/test_with_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,39 @@ on:
- cron: '0 0 * * *'

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.1', '7.2', '7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
stability: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }} Test

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom
coverage: xdebug
tools: composer

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: cache-php-${{ matrix.php-versions }}-composer-${{ hashFiles('composer.json') }}

- name: Run test suite
run: |
composer install
composer test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, dom
coverage: xdebug
tools: composer:v2

- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Run test suite
run: composer test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "FINDOLOGIC export toolkit for XML and CSV data export",
"homepage": "https://github.com/findologic/libflexport",
"require": {
"php": "^7.1",
"php": "^7.1|^8.0",
"ext-dom": "*",
"ext-mbstring": "*",
"findologic/xml-export-schema": "^1.4"
Expand Down Expand Up @@ -54,5 +54,6 @@
"psr-0": {
"FINDOLOGIC\\Export\\Tests\\": "tests/"
}
}
},
"prefer-stable": true
}
6 changes: 2 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
Expand All @@ -20,7 +18,7 @@
</filter>

<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
<log type="coverage-text" target="php://stdout"/>
<log type="coverage-clover" target="./coverage.xml"/>
</logging>
</phpunit>
1 change: 0 additions & 1 deletion tests/FINDOLOGIC/Export/Tests/CSVSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use FINDOLOGIC\Export\Helpers\UsergroupAwareMultiValueItem;
use FINDOLOGIC\Export\Helpers\UsergroupAwareSimpleValue;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

class CSVSerializationTest extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/FINDOLOGIC/Export/Tests/DataElementsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use FINDOLOGIC\Export\Exceptions\ValueIsNotNumericException;
use FINDOLOGIC\Export\Exceptions\ValueIsNotPositiveIntegerException;
use FINDOLOGIC\Export\Helpers\UsergroupAwareSimpleValue;
use PHPUnit\Framework\TestCase;

class DataElementsTest extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/FINDOLOGIC/Export/Tests/DataHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use FINDOLOGIC\Export\Exceptions\ValueIsNotNumericException;
use FINDOLOGIC\Export\Helpers\DataHelper;
use FINDOLOGIC\Export\Helpers\NameAwareValue;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionException;

Expand Down
1 change: 0 additions & 1 deletion tests/FINDOLOGIC/Export/Tests/ExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use FINDOLOGIC\Export\Exporter;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

class ExporterTest extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/FINDOLOGIC/Export/Tests/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use FINDOLOGIC\Export\Data\Property;
use FINDOLOGIC\Export\Exporter;
use FINDOLOGIC\Export\XML\XMLExporter;
use PHPUnit\Framework\TestCase;

class ItemTest extends TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/FINDOLOGIC/Export/Tests/PropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Exception;
use FINDOLOGIC\Export\Data\Property;
use FINDOLOGIC\Export\Exceptions\DuplicateValueForUsergroupException;
use PHPUnit\Framework\TestCase;

class PropertyTest extends TestCase
{
Expand Down Expand Up @@ -59,7 +58,7 @@ public function testReservedPropertyKeysCausesException(string $key, bool $shoul
$this->assertNotNull($property);
}
} catch (Exception $exception) {
$this->assertRegExp('/' . $key . '/', $exception->getMessage());
$this->assertMatchesRegularExpression('/' . $key . '/', $exception->getMessage());
}
}

Expand Down
17 changes: 17 additions & 0 deletions tests/FINDOLOGIC/Export/Tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace FINDOLOGIC\Export\Tests;

use PHPUnit\Framework\TestCase as BaseTestCase;

class TestCase extends BaseTestCase
{
public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
{
if (method_exists(BaseTestCase::class, 'assertMatchesRegularExpression')) {
parent::assertMatchesRegularExpression($pattern, $string, $message);
} else {
parent::assertRegExp($pattern, $string, $message);
}
}
}
1 change: 0 additions & 1 deletion tests/FINDOLOGIC/Export/Tests/XmlSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use FINDOLOGIC\Export\XML\XMLExporter;
use FINDOLOGIC\Export\XML\XMLItem;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use stdClass;

/**
Expand Down