Skip to content

Commit ff9cdac

Browse files
authored
Merge pull request #14 from SimonFrings/tests
Run tests on PHP 8, PHP 7.4 and PHPUnit 9 and update PHPUnit configuration schema for PHPUnit 9.3
2 parents e06d12d + b2f58e8 commit ff9cdac

File tree

7 files changed

+65
-21
lines changed

7 files changed

+65
-21
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.gitattributes export-ignore
2+
/.github/workflows/ export-ignore
3+
/.gitignore export-ignore
4+
/examples/ export-ignore
5+
/phpunit.xml.dist export-ignore
6+
/phpunit.xml.legacy export-ignore
7+
/tests/ export-ignore

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
strategy:
1111
matrix:
1212
php:
13+
- 8.0
14+
- 7.4
15+
- 7.3
1316
- 7.2
1417
- 7.1
1518
- 7.0
@@ -25,6 +28,9 @@ jobs:
2528
php-version: ${{ matrix.php }}
2629
- run: composer install
2730
- run: vendor/bin/phpunit --coverage-text
31+
if: ${{ matrix.php >= 7.3 }}
32+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
33+
if: ${{ matrix.php < 7.3 }}
2834

2935
PHPUnit-hhvm:
3036
name: PHPUnit (HHVM)
@@ -34,6 +40,5 @@ jobs:
3440
- uses: azjezz/setup-hhvm@v1
3541
with:
3642
version: lts-3.30
37-
- run: hhvm $(which composer) require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit
3843
- run: hhvm $(which composer) install
3944
- run: hhvm vendor/bin/phpunit

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ $ composer require clue/arguments:^2.0
234234
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
235235

236236
This project aims to run on any platform and thus does not require any PHP
237-
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
237+
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
238238
HHVM.
239239
It's *highly recommended to use PHP 7+* for this project.
240240

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"php": ">=5.3"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35"
17+
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
1818
},
1919
"autoload": {
2020
"files": [ "src/functions.php" ],

phpunit.xml.dist

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit bootstrap="vendor/autoload.php" colors="true">
3+
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
cacheResult="false">
49
<testsuites>
5-
<testsuite>
10+
<testsuite name="Arguments test suite">
611
<directory>./tests/</directory>
712
</testsuite>
813
</testsuites>
9-
<filter>
10-
<whitelist>
14+
<coverage>
15+
<include>
1116
<directory>./src/</directory>
12-
</whitelist>
13-
</filter>
17+
</include>
18+
</coverage>
1419
</phpunit>

phpunit.xml.legacy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
6+
bootstrap="vendor/autoload.php"
7+
colors="true">
8+
<testsuites>
9+
<testsuite name="Arguments test suite">
10+
<directory>./tests/</directory>
11+
</testsuite>
12+
</testsuites>
13+
<filter>
14+
<whitelist>
15+
<directory>./src/</directory>
16+
</whitelist>
17+
</filter>
18+
</phpunit>

tests/SplitTest.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,21 @@ public function testSingleStringWithDoubleQuotesAndEscapedQuote()
9696
$this->assertEquals(array('he"llo'), $args);
9797
}
9898

99-
/**
100-
* @expectedException Clue\Arguments\UnclosedQuotesException
101-
*/
10299
public function testSingleStringWithUnbalancedDoubleQuotesThrows()
103100
{
101+
$this->setExpectedException('Clue\Arguments\UnclosedQuotesException');
104102
Arguments\split('"hello');
105103
}
106104

107-
/**
108-
* @expectedException Clue\Arguments\UnclosedQuotesException
109-
*/
110105
public function testSingleStringWithUnbalancedSingleQuotesThrows()
111106
{
107+
$this->setExpectedException('Clue\Arguments\UnclosedQuotesException');
112108
Arguments\split("'hello");
113109
}
114110

115-
/**
116-
* @expectedException Clue\Arguments\UnclosedQuotesException
117-
*/
118111
public function testSimpleStringWithUnbalancedSingleQuotesThrows()
119112
{
113+
$this->setExpectedException('Clue\Arguments\UnclosedQuotesException');
120114
Arguments\split("echo let's go");
121115
}
122116

@@ -134,11 +128,9 @@ public function testDoubleQuotedWithAppendedString()
134128
$this->assertEquals(array('hello'), $args);
135129
}
136130

137-
/**
138-
* @expectedException Clue\Arguments\UnclosedQuotesException
139-
*/
140131
public function testSimpleStringWithUnbalancedDoubleQuotesThrows()
141132
{
133+
$this->setExpectedException('Clue\Arguments\UnclosedQuotesException');
142134
Arguments\split('hello "world');
143135
}
144136

@@ -316,4 +308,21 @@ public function testSingleStringWithCombinedSingleQuotedPartsWithInterpretedEsca
316308

317309
$this->assertEquals(array("\n\\n\n"), $args);
318310
}
311+
312+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
313+
{
314+
if (method_exists($this, 'expectException')) {
315+
// PHPUnit 5.2+
316+
$this->expectException($exception);
317+
if ($exceptionMessage !== '') {
318+
$this->expectExceptionMessage($exceptionMessage);
319+
}
320+
if ($exceptionCode !== null) {
321+
$this->expectExceptionCode($exceptionCode);
322+
}
323+
} else {
324+
// legacy PHPUnit 4 - PHPUnit 5.1
325+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
326+
}
327+
}
319328
}

0 commit comments

Comments
 (0)