From 4c67d25d39c1612e393bc329a82eab47da74c001 Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Tue, 1 Feb 2022 12:33:52 +0000 Subject: [PATCH] Update to PHPUnit 9 (#31) --- composer.json | 4 ++-- phpunit.xml.dist | 25 +++++++++++-------------- test/FilterTest.php | 4 ++-- test/MapTest.php | 4 ++-- test/ParallelTest.php | 12 ++++++++---- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 759a2dc..855a2fe 100644 --- a/composer.json +++ b/composer.json @@ -29,9 +29,9 @@ "opis/closure": "^3.0.7" }, "require-dev": { - "amphp/phpunit-util": "^1.0", + "amphp/phpunit-util": "^2.0", "friendsofphp/php-cs-fixer": "^2.9", - "phpunit/phpunit": "^6.5" + "phpunit/phpunit": "^9.5.11" }, "config": { "platform": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3a86845..b8da342 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,13 @@ - - - - test - - - - - src - - - - - + + + + src + + + + + test + + diff --git a/test/FilterTest.php b/test/FilterTest.php index 8a0edd1..04651f5 100644 --- a/test/FilterTest.php +++ b/test/FilterTest.php @@ -3,11 +3,11 @@ namespace Amp\ParallelFunctions\Test; use Amp\MultiReasonException; -use Amp\PHPUnit\TestCase; use function Amp\ParallelFunctions\parallelFilter; +use Amp\PHPUnit\AsyncTestCase; use function Amp\Promise\wait; -class FilterTest extends TestCase { +class FilterTest extends AsyncTestCase { public function testWithoutCallback() { $input = [1, 0, 3, false, true, null]; diff --git a/test/MapTest.php b/test/MapTest.php index e2a2d60..6e515e8 100644 --- a/test/MapTest.php +++ b/test/MapTest.php @@ -3,11 +3,11 @@ namespace Amp\ParallelFunctions\Test; use Amp\MultiReasonException; -use Amp\PHPUnit\TestCase; use function Amp\ParallelFunctions\parallelMap; +use Amp\PHPUnit\AsyncTestCase; use function Amp\Promise\wait; -class MapTest extends TestCase { +class MapTest extends AsyncTestCase { public function testValidInput() { $this->assertSame([3, 4, 5], wait(parallelMap([1, 2, 3], function ($input) { return $input + 2; diff --git a/test/ParallelTest.php b/test/ParallelTest.php index 156f225..8bfa00a 100644 --- a/test/ParallelTest.php +++ b/test/ParallelTest.php @@ -4,11 +4,11 @@ namespace Amp\ParallelFunctions\Test; use Amp\Parallel\Sync\SerializationException; use Amp\Parallel\Worker\Pool; +use function Amp\ParallelFunctions\parallel; use Amp\ParallelFunctions\Test\Fixture\TestCallables; -use Amp\PHPUnit\TestCase; +use Amp\PHPUnit\AsyncTestCase; use Amp\Promise; use Amp\Success; -use function Amp\ParallelFunctions\parallel; class UnserializableClass { public function __invoke() { @@ -21,7 +21,7 @@ class UnserializableClass { } } -class ParallelTest extends TestCase { +class ParallelTest extends AsyncTestCase { public function testUnserializableClosure() { $this->expectException(SerializationException::class); $this->expectExceptionMessage("Unsupported callable: Serialization of 'class@anonymous' is not allowed"); @@ -108,7 +108,11 @@ class ParallelTest extends TestCase { public function testUnserializableClassStaticMethod() { $this->expectException(\Error::class); - $this->expectExceptionMessage('Uncaught Error in worker with message "Class \'Amp\\ParallelFunctions\\Test\\UnserializableClass\' not found"'); + $this->expectExceptionMessage( + PHP_VERSION_ID >= 80000 ? + 'Uncaught Error in worker with message "Class "Amp\\ParallelFunctions\\Test\\UnserializableClass" not found"' : + 'Uncaught Error in worker with message "Class \'Amp\\ParallelFunctions\\Test\\UnserializableClass\' not found"' + ); $callable = [UnserializableClass::class, 'staticMethod'];