Update to PHPUnit 9 (#31)

This commit is contained in:
Owen Voke 2022-02-01 12:33:52 +00:00 committed by GitHub
parent 14ff70bceb
commit 4c67d25d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 24 deletions

View File

@ -29,9 +29,9 @@
"opis/closure": "^3.0.7" "opis/closure": "^3.0.7"
}, },
"require-dev": { "require-dev": {
"amphp/phpunit-util": "^1.0", "amphp/phpunit-util": "^2.0",
"friendsofphp/php-cs-fixer": "^2.9", "friendsofphp/php-cs-fixer": "^2.9",
"phpunit/phpunit": "^6.5" "phpunit/phpunit": "^9.5.11"
}, },
"config": { "config": {
"platform": { "platform": {

View File

@ -1,16 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.0/phpunit.xsd"> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd">
<testsuites> <coverage>
<testsuite name="Main"> <include>
<directory>test</directory> <directory suffix=".php">src</directory>
</testsuite> </include>
</testsuites> </coverage>
<filter> <testsuites>
<whitelist> <testsuite name="Main">
<directory suffix=".php">src</directory> <directory>test</directory>
</whitelist> </testsuite>
</filter> </testsuites>
<listeners>
<listener class="Amp\PHPUnit\LoopReset"/>
</listeners>
</phpunit> </phpunit>

View File

@ -3,11 +3,11 @@
namespace Amp\ParallelFunctions\Test; namespace Amp\ParallelFunctions\Test;
use Amp\MultiReasonException; use Amp\MultiReasonException;
use Amp\PHPUnit\TestCase;
use function Amp\ParallelFunctions\parallelFilter; use function Amp\ParallelFunctions\parallelFilter;
use Amp\PHPUnit\AsyncTestCase;
use function Amp\Promise\wait; use function Amp\Promise\wait;
class FilterTest extends TestCase { class FilterTest extends AsyncTestCase {
public function testWithoutCallback() { public function testWithoutCallback() {
$input = [1, 0, 3, false, true, null]; $input = [1, 0, 3, false, true, null];

View File

@ -3,11 +3,11 @@
namespace Amp\ParallelFunctions\Test; namespace Amp\ParallelFunctions\Test;
use Amp\MultiReasonException; use Amp\MultiReasonException;
use Amp\PHPUnit\TestCase;
use function Amp\ParallelFunctions\parallelMap; use function Amp\ParallelFunctions\parallelMap;
use Amp\PHPUnit\AsyncTestCase;
use function Amp\Promise\wait; use function Amp\Promise\wait;
class MapTest extends TestCase { class MapTest extends AsyncTestCase {
public function testValidInput() { public function testValidInput() {
$this->assertSame([3, 4, 5], wait(parallelMap([1, 2, 3], function ($input) { $this->assertSame([3, 4, 5], wait(parallelMap([1, 2, 3], function ($input) {
return $input + 2; return $input + 2;

View File

@ -4,11 +4,11 @@ namespace Amp\ParallelFunctions\Test;
use Amp\Parallel\Sync\SerializationException; use Amp\Parallel\Sync\SerializationException;
use Amp\Parallel\Worker\Pool; use Amp\Parallel\Worker\Pool;
use function Amp\ParallelFunctions\parallel;
use Amp\ParallelFunctions\Test\Fixture\TestCallables; use Amp\ParallelFunctions\Test\Fixture\TestCallables;
use Amp\PHPUnit\TestCase; use Amp\PHPUnit\AsyncTestCase;
use Amp\Promise; use Amp\Promise;
use Amp\Success; use Amp\Success;
use function Amp\ParallelFunctions\parallel;
class UnserializableClass { class UnserializableClass {
public function __invoke() { public function __invoke() {
@ -21,7 +21,7 @@ class UnserializableClass {
} }
} }
class ParallelTest extends TestCase { class ParallelTest extends AsyncTestCase {
public function testUnserializableClosure() { public function testUnserializableClosure() {
$this->expectException(SerializationException::class); $this->expectException(SerializationException::class);
$this->expectExceptionMessage("Unsupported callable: Serialization of 'class@anonymous' is not allowed"); $this->expectExceptionMessage("Unsupported callable: Serialization of 'class@anonymous' is not allowed");
@ -108,7 +108,11 @@ class ParallelTest extends TestCase {
public function testUnserializableClassStaticMethod() { public function testUnserializableClassStaticMethod() {
$this->expectException(\Error::class); $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']; $callable = [UnserializableClass::class, 'staticMethod'];