8000 Merge pull request #18 from SimonFrings/phpunit · clue/reactphp-packagist-api@6c2d136 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c2d136

Browse files
authored
Merge pull request #18 from SimonFrings/phpunit
Support PHP 8 and run tests on PHPUnit 9
2 parents 7c103be + f400646 commit 6c2d136

File tree

8 files changed

+46
-9
lines changed

8 files changed

+46
-9
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/.gitignore export-ignore
44
/examples/ export-ignore
55
/phpunit.xml.dist export-ignore
6+
/phpunit.xml.legacy export-ignore
67
/tests/ export-ignore

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
php:
14+
- 8.0
1415
- 7.4
1516
- 7.3
1617
- 7.2
@@ -28,6 +29,9 @@ jobs:
2829
coverage: xdebug
2930
- run: composer install
3031
- run: vendor/bin/phpunit --coverage-text
32+
if: ${{ matrix.php >= 7.3 }}
33+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
34+
if: ${{ matrix.php < 7.3 }}
3135

3236
PHPUnit-hhvm:
3337
name: PHPUnit (HHVM)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ $ composer require clue/packagist-api-react:^1.3
240240
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
241241

242242
This project aims to run on any platform and thus does not require any PHP
243-
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
243+
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
244244
HHVM.
245245
It's *highly recommended to use PHP 7+* for this project.
246246

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"rize/uri-template": "^0.3"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35"
20+
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
2121
},
2222
"autoload": {
2323
"psr-4": { "Clue\\React\\Packagist\\Api\\": "src/" }

phpunit.xml.dist

Lines changed: 10 additions & 5 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>
510
<testsuite name="Packagist React 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="Packagist React 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/ClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class ClientTest extends TestCase
1212
private $browser;
1313
private $client;
1414

15-
public function setUp()
15+
/**
16+
* @before
17+
*/
18+
public function setUpClient()
1619
{
1720
$this->browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
1821
$this->browser->expects($this->any())->method('withBase')->willReturn($this->browser);

tests/TestCase.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ protected function expectCallableOnceParameter($type)
4646

4747
protected function createCallableMock()
4848
{
49-
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
49+
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
50+
// PHPUnit 8.5+
51+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
52+
} else {
53+
// legacy PHPUnit 4 - PHPUnit 8.4
54+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
55+
}
5056
}
5157

5258
protected function expectPromiseResolve($promise)

0 commit comments

Comments
 (0)
0