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

Run tests on PHP 8, PHP 7.4 and PHPUnit 9 and update PHPUnit configuration schema for PHPUnit 9.3 #14

Merged
merged 4 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
strategy:
matrix:
php:
- 8.0
- 7.4
- 7.3
- 7.2
- 7.1
- 7.0
Expand All @@ -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)
Expand All @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ],
Expand Down
17 changes: 11 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php" colors="true">
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheResult="false">
<testsuites>
<testsuite>
<testsuite name="Arguments test suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory>./src/</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
18 changes: 18 additions & 0 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Arguments test suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
33 changes: 21 additions & 12 deletions tests/SplitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -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');
}

Expand Down Expand Up @@ -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);
}
}
}