From ab90986783f57d22f910783a2a1b12dd23ecdf66 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 8 Dec 2020 12:30:27 +0100 Subject: [PATCH 1/4] Run tests on PHP 7.4 and PHPUnit 9 --- .github/workflows/ci.yml | 3 ++- composer.json | 2 +- tests/SplitTest.php | 33 +++++++++++++++++++++------------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd3f079..78710b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,8 @@ jobs: strategy: matrix: php: + - 7.4 + - 7.3 - 7.2 - 7.1 - 7.0 @@ -34,6 +36,5 @@ jobs: - uses: azjezz/setup-hhvm@v1 with: version: lts-3.30 - - run: hhvm $(which composer) require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit - run: hhvm $(which composer) install - run: hhvm vendor/bin/phpunit diff --git a/composer.json b/composer.json index 544ef7f..cecadbc 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" }, "autoload": { "files": [ "src/functions.php" ], diff --git a/tests/SplitTest.php b/tests/SplitTest.php index 76b7101..6b97da8 100644 --- a/tests/SplitTest.php +++ b/tests/SplitTest.php @@ -96,27 +96,21 @@ public function testSingleStringWithDoubleQuotesAndEscapedQuote() $this->assertEquals(array('he"llo'), $args); } - /** - * @expectedException Clue\Arguments\UnclosedQuotesException - */ public function testSingleStringWithUnbalancedDoubleQuotesThrows() { + $this->setExpectedException('Clue\Arguments\UnclosedQuotesException'); Arguments\split('"hello'); } - /** - * @expectedException Clue\Arguments\UnclosedQuotesException - */ public function testSingleStringWithUnbalancedSingleQuotesThrows() { + $this->setExpectedException('Clue\Arguments\UnclosedQuotesException'); Arguments\split("'hello"); } - /** - * @expectedException Clue\Arguments\UnclosedQuotesException - */ public function testSimpleStringWithUnbalancedSingleQuotesThrows() { + $this->setExpectedException('Clue\Arguments\UnclosedQuotesException'); Arguments\split("echo let's go"); } @@ -134,11 +128,9 @@ public function testDoubleQuotedWithAppendedString() $this->assertEquals(array('hello'), $args); } - /** - * @expectedException Clue\Arguments\UnclosedQuotesException - */ public function testSimpleStringWithUnbalancedDoubleQuotesThrows() { + $this->setExpectedException('Clue\Arguments\UnclosedQuotesException'); Arguments\split('hello "world'); } @@ -316,4 +308,21 @@ public function testSingleStringWithCombinedSingleQuotedPartsWithInterpretedEsca $this->assertEquals(array("\n\\n\n"), $args); } + + 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); + } + } } From 1f4d026e189e385201ebd2ce320479f69912f207 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 8 Dec 2020 12:33:53 +0100 Subject: [PATCH 2/4] Update PHPUnit configuration schema for PHPUnit 9.3 --- .github/workflows/ci.yml | 3 +++ phpunit.xml.dist | 17 +++++++++++------ phpunit.xml.legacy | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 phpunit.xml.legacy diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78710b6..078a8e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: php-version: ${{ matrix.php }} - 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 a6e2430..dc332ca 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,19 @@ - + + - + ./tests/ - - + + ./src/ - - + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 0000000..8000c04 --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,18 @@ + + + + + + + ./tests/ + + + + + ./src/ + + + From 6f2b2bec4be02284c2f1d76ecd8d55f16b4a2883 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 8 Dec 2020 12:36:22 +0100 Subject: [PATCH 3/4] Add .gitattributes to exclude dev files from exports --- .gitattributes | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..da20d18 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +/.gitattributes export-ignore +/.github/workflows/ export-ignore +/.gitignore export-ignore +/examples/ export-ignore +/phpunit.xml.dist export-ignore +/phpunit.xml.legacy export-ignore +/tests/ export-ignore From b2f58e851e565d1f909d100f1623d33d636024e3 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Tue, 8 Dec 2020 12:36:32 +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 078a8e1..38ed72e 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 9ea85c4..0a6d18f 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ $ composer require clue/arguments:^2.0 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.