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 PHPUnit 9 and update PHPUnit configuration schema for PHPUnit 9.3 #31

Merged
merged 2 commits into from
Dec 21, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.gitignore export-ignore
/examples/ export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml.legacy export-ignore
/tests/ export-ignore
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ jobs:
coverage: xdebug
- 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 }}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react/stream": "^1.0 || ^0.7 || ^0.6"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^6.0",
"phpunit/phpunit": "^9.3 || ^6.5",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3"
},
"suggest": {
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 name="zlib React Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
</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/6.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="zlib React Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
4 changes: 1 addition & 3 deletions tests/CompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

class CompressorTest extends TestCase
{
/**
* @expectedException InvalidArgumentException
*/
public function testCtorThrowsForInvalidEncoding()
{
$this->expectException('InvalidArgumentException');
new Compressor(0);
}
}
4 changes: 1 addition & 3 deletions tests/DecompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

class DecompressorTest extends TestCase
{
/**
* @expectedException InvalidArgumentException
*/
public function testCtorThrowsForInvalidEncoding()
{
$this->expectException('InvalidArgumentException');
new Decompressor(0);
}
}
5 changes: 4 additions & 1 deletion tests/DeflateDecompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class DeflateDecompressorTest extends TestCase
{
private $decompressor;

public function setUp()
/**
* @before
*/
public function setUpDecompressor()
{
$this->decompressor = new Decompressor(ZLIB_ENCODING_RAW);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/DelateCompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class DeflateCompressorTest extends TestCase
{
private $compressor;

public function setUp()
/**
* @before
*/
public function setUpCompressor()
{
$this->compressor = new Compressor(ZLIB_ENCODING_RAW);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/FunctionalExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

class FunctionalExamplesTest extends TestCase
{
public function setUp()
/**
* @before
*/
public function setUpSkipTest()
{
if (DIRECTORY_SEPARATOR === '\\') {
$this->markTestSkipped('Non-blocking console I/O not supported on Windows');
Expand Down
5 changes: 4 additions & 1 deletion tests/GzipCompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class GzipCompressorTest extends TestCase
{
private $compressor;

public function setUp()
/**
* @before
*/
public function setUpCompressor()
{
$this->compressor = new Compressor(ZLIB_ENCODING_GZIP);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/GzipDecompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class GzipDecompressorTest extends TestCase
{
private $decompressor;

public function setUp()
/**
* @before
*/
public function setUpDecompressor()
{
$this->decompressor = new Decompressor(ZLIB_ENCODING_GZIP);
}
Expand Down
8 changes: 7 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ protected function expectCallableNever()

protected function createCallableMock()
{
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
// PHPUnit 8.5+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
} else {
// legacy PHPUnit 4 - PHPUnit 8.4
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
}
}
}
5 changes: 4 additions & 1 deletion tests/ZlibCompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class ZlibCompressorTest extends TestCase
{
private $compressor;

public function setUp()
/**
* @before
*/
public function setUpCompressor()
{
$this->compressor = new Compressor(ZLIB_ENCODING_DEFLATE);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/ZlibDecompressorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class ZlibDecompressorTest extends TestCase
{
private $decompressor;

public function setUp()
/**
* @before
*/
public function setUpDecompressor()
{
$this->decompressor = new Decompressor(ZLIB_ENCODING_DEFLATE);
}
Expand Down