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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd3f079..38ed72e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,9 @@ jobs: strategy: matrix: php: + - 8.0 + - 7.4 + - 7.3 - 7.2 - 7.1 - 7.0 @@ -25,6 +28,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) @@ -34,6 +40,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/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. 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/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/ + + + 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); + } + } }