From 20f46c85c750cb6249c817552298a727725395f7 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Fri, 18 Dec 2020 14:33:42 +0100 Subject: [PATCH 1/4] Run tests on PHPUnit 9 --- .github/workflows/ci.yml | 7 +++++++ README.md | 7 +++++++ composer.json | 2 +- phpunit.xml.dist | 2 +- tests/StreamingJsonParserTest.php | 28 +++++++++++++++++++++++----- tests/bootstrap.php | 6 ------ 6 files changed, 39 insertions(+), 13 deletions(-) delete mode 100644 tests/bootstrap.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03dce0a..67ef0c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,14 @@ jobs: strategy: matrix: php: + - 7.4 + - 7.3 + - 7.2 + - 7.1 + - 7.0 - 5.6 + - 5.5 + - 5.4 - 5.3 steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index eaea3cd..eaec476 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,13 @@ The recommended way to install this library is [through Composer](https://getcom } ``` +See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. + +This project aims to run on any platform and thus does not require any PHP +extensions and supports running on legacy PHP 5.3 through current PHP 7+ and +HHVM. +It's *highly recommended to use PHP 7+* for this project. + ## Tests To run the test suite, you first need to clone this repo and then install all diff --git a/composer.json b/composer.json index f3ab97e..25a3918 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,6 @@ "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": "^4.8.35" + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 50b416a..ee4ff29 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ -parser = new StreamingJsonParser(); } @@ -57,11 +60,26 @@ public function testMultipleObjectAndArray() $this->assertTrue($this->parser->isEmpty()); } - /** - * @expectedException UnexpectedValueException - */ public function testInvalid() { + $this->setExpectedException('UnexpectedValueException'); $this->parser->push('invalid'); } + + public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null) + { + if (method_exists($this, 'expectException')) { + // PHPUnit 5.2+ + $this->expectException($exception); + if ($exceptionMessage !== '') { + $this->expectExceptionMessage($exceptionMessage); + } + if ($exceptionCode !== null) { + $this->expectExceptionCode($exceptionCode); + } + } else { + // legacy PHPUnit 4 - PHPUnit 5.1 + parent::setExpectedException($exception, $exceptionMessage, $exceptionCode); + } + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 75d2f64..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,6 +0,0 @@ - Date: Fri, 18 Dec 2020 14:37:03 +0100 Subject: [PATCH 2/4] Update PHPUnit configuration schema for PHPUnit 9.3 --- .github/workflows/ci.yml | 3 +++ phpunit.xml.dist | 22 +++++++++++----------- phpunit.xml.legacy | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 phpunit.xml.legacy diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67ef0c3..f84ddb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,9 @@ jobs: coverage: xdebug - run: composer install - run: vendor/bin/phpunit --coverage-text + if: ${{ matrix.php >= 7.3 }} + - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + if: ${{ matrix.php < 7.3 }} PHPUnit-hhvm: name: PHPUnit (HHVM) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ee4ff29..9fa793c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,19 @@ - + + cacheResult="false"> - + ./tests/ - - + + ./src/ - - - \ No newline at end of file + + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 0000000..4e8f2ac --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,18 @@ + + + + + + + ./tests/ + + + + + ./src/ + + + From ecf32a1195b12c4d1498d8fd0bbfdd3889f7436f Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Fri, 18 Dec 2020 14:38:37 +0100 Subject: [PATCH 3/4] Add .gitattributes to exclude dev files from exports --- .gitattributes | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94cd213 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.gitattributes export-ignore +/.github/workflows/ export-ignore +/.gitignore export-ignore +/phpunit.xml.dist export-ignore +/phpunit.xml.legacy export-ignore +/tests/ export-ignore From 21a130214b2c4892718fdef07bf49662a8f02961 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Fri, 18 Dec 2020 14:40:45 +0100 Subject: [PATCH 4/4] Support PHP 8 --- .github/workflows/ci.yml | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f84ddb5..d0bae62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ jobs: strategy: matrix: php: + - 8.0 - 7.4 - 7.3 - 7.2 diff --git a/README.md b/README.md index eaec476..e98108b 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ The recommended way to install this library is [through Composer](https://getcom See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP -extensions and supports running on legacy PHP 5.3 through current PHP 7+ and +extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's *highly recommended to use PHP 7+* for this project.