From 4b1835b8fd03536e2758b618a7a977037c82fdf1 Mon Sep 17 00:00:00 2001 From: Valentin CLARAS Date: Wed, 1 Sep 2021 12:54:32 +0200 Subject: [PATCH 1/5] feat: remove support for deprecated version of php --- .github/workflows/ci.yml | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe463ba..025419d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php: [ '7.2', '7.3', '7.4' ] + php: [ '7.3', '7.4' ] steps: - name: 'Init repository' diff --git a/composer.json b/composer.json index 556d560..bf61486 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ } }, "require": { - "php": "^7.1", + "php": "^7.3", "psr/http-message": "^1.0" }, "require-dev": { @@ -28,7 +28,7 @@ "amphp/amp": "^2.0", "guzzlehttp/guzzle": "^6.3", "m6web/php-cs-fixer-config": "^2.0", - "ext-curl": "^7.1", + "ext-curl": "^7.3", "react/event-loop": "^1.0", "react/promise": "^2.7", "phpstan/phpstan": "^0.12", From bb0f4fda97c10a4c29c01743b5d643b0509fc8f2 Mon Sep 17 00:00:00 2001 From: Valentin CLARAS Date: Wed, 1 Sep 2021 12:55:54 +0200 Subject: [PATCH 2/5] feat: add build and support for php 8.0 --- .github/workflows/ci.yml | 2 +- .gitignore | 1 + composer.json | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 025419d..6ba4149 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php: [ '7.3', '7.4' ] + php: [ '7.3', '7.4', '8.0' ] steps: - name: 'Init repository' diff --git a/.gitignore b/.gitignore index 40f9b08..184b211 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /vendor/ /composer.lock /.php-cs-fixer.cache +/.phpunit.result.cache diff --git a/composer.json b/composer.json index bf61486..931ab32 100644 --- a/composer.json +++ b/composer.json @@ -20,15 +20,15 @@ } }, "require": { - "php": "^7.3", + "php": "^7.3|^8.0", "psr/http-message": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^7.3", + "phpunit/phpunit": "^9.4.4", "amphp/amp": "^2.0", "guzzlehttp/guzzle": "^6.3", "m6web/php-cs-fixer-config": "^2.0", - "ext-curl": "^7.3", + "ext-curl": "^7.3|^8.0", "react/event-loop": "^1.0", "react/promise": "^2.7", "phpstan/phpstan": "^0.12", From ddeb825b58c889338a6b8b223896ae400235d797 Mon Sep 17 00:00:00 2001 From: Valentin Claras Date: Thu, 18 Mar 2021 20:25:31 +0100 Subject: [PATCH 3/5] fix: update phpunit assert string contains --- tests/HttpClientTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/HttpClientTest.php b/tests/HttpClientTest.php index e3d89f6..7c40acd 100644 --- a/tests/HttpClientTest.php +++ b/tests/HttpClientTest.php @@ -40,7 +40,7 @@ public function testGetValidUrl(EventLoop $eventLoop): void $response = $eventLoop->wait($httpClient->sendRequest($request)); $this->assertSame(200, $response->getStatusCode()); - $this->assertContains('This is a test', (string) $response->getBody()); + $this->assertStringContainsString('This is a test', (string) $response->getBody()); } /** @@ -75,7 +75,7 @@ public function testGetServerErrorUrl(EventLoop $eventLoop): void $response = $eventLoop->wait($httpClient->sendRequest($request)); $this->assertSame(500, $response->getStatusCode()); - $this->assertContains('Error', (string) $response->getBody()); + $this->assertStringContainsString('Error', (string) $response->getBody()); } /** @@ -112,11 +112,11 @@ public function testSynchronousRequests(EventLoop $eventLoop): void $response = $eventLoop->wait($httpClient->sendRequest($request)); $this->assertSame(200, $response->getStatusCode()); - $this->assertContains('Example Domain', (string) $response->getBody()); + $this->assertStringContainsString('Example Domain', (string) $response->getBody()); $response = $eventLoop->wait($httpClient->sendRequest($request)); $this->assertSame(200, $response->getStatusCode()); - $this->assertContains('Example Domain', (string) $response->getBody()); + $this->assertStringContainsString('Example Domain', (string) $response->getBody()); } /** From 516c0e52c52af3db29a4605093535e47549151f2 Mon Sep 17 00:00:00 2001 From: Valentin CLARAS Date: Thu, 2 Sep 2021 08:37:40 +0200 Subject: [PATCH 4/5] fix: migrate phpunit configuration --- phpunit.xml.dist | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 325e018..7c0069f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,32 +1,28 @@ - - - - - - - - - - - - tests - - - examples/tests - - - - - - src - - + + + src + + + + + + + + + + + tests + + + examples/tests + + From db42b737916f1c8de8daf6b07328e90e1f6b372e Mon Sep 17 00:00:00 2001 From: Valentin CLARAS Date: Thu, 2 Sep 2021 17:33:29 +0200 Subject: [PATCH 5/5] feat: remove test on stream connection closed as handling differs between implementation --- src/EventLoop.php | 2 ++ tests/Adapter/Amp/EventLoopTest.php | 16 --------- tests/EventLoopTest/StreamsTest.php | 50 ----------------------------- 3 files changed, 2 insertions(+), 66 deletions(-) diff --git a/src/EventLoop.php b/src/EventLoop.php index f249583..fddd33f 100644 --- a/src/EventLoop.php +++ b/src/EventLoop.php @@ -69,6 +69,7 @@ public function deferred(): Deferred; /** * Returns a promise that will be resolved with the input stream when it becomes readable. + * ⚠️ Error handling (stream connection closed for example) might differ between implementations. * * @param resource $stream */ @@ -76,6 +77,7 @@ public function readable($stream): Promise; /** * Returns a promise that will be resolved with the input stream when it becomes writable. + * ⚠️ Error handling (stream connection closed for example) might differ between implementations. * * @param resource $stream */ diff --git a/tests/Adapter/Amp/EventLoopTest.php b/tests/Adapter/Amp/EventLoopTest.php index 9e29bc5..00bed3b 100644 --- a/tests/Adapter/Amp/EventLoopTest.php +++ b/tests/Adapter/Amp/EventLoopTest.php @@ -17,20 +17,4 @@ public function testStreamShouldReadFromWritable(string $expectedSequence = ''): // Because Amp resolve promises in a slightly different order. parent::testStreamShouldReadFromWritable('W0R0W12345R12R34W6R56R'); } - - public function testStreamShouldNotBeWritableIfClosed(): void - { - assert_options(ASSERT_EXCEPTION, 1); - $this->expectException(\Throwable::class); - - parent::testStreamShouldNotBeWritableIfClosed(); - } - - public function testStreamShouldNotBeReadableIfClosed(): void - { - assert_options(ASSERT_EXCEPTION, 1); - $this->expectException(\Throwable::class); - - parent::testStreamShouldNotBeReadableIfClosed(); - } } diff --git a/tests/EventLoopTest/StreamsTest.php b/tests/EventLoopTest/StreamsTest.php index 5c0e1ab..802d640 100644 --- a/tests/EventLoopTest/StreamsTest.php +++ b/tests/EventLoopTest/StreamsTest.php @@ -80,54 +80,4 @@ public function testStreamShouldBeWritableIfOpened(): void $stream = $eventLoop->wait($eventLoop->writable($streamIn)); $this->assertSame($streamIn, $stream); } - - public function testStreamShouldNotBeWritableIfClosed(): void - { - $eventLoop = $this->createEventLoop(); - [$streamIn, $streamOut] = $this->createStreamPair(); - - $waitSomeTicks = function () use ($eventLoop) { - yield $eventLoop->idle(); - yield $eventLoop->idle(); - yield $eventLoop->idle(); - - return 'Aborted'; - }; - - // If stream is closed, the promise will never be resolved - fclose($streamIn); - $result = $eventLoop->wait( - $eventLoop->promiseRace( - $eventLoop->async($waitSomeTicks()), - $eventLoop->writable($streamIn) - ) - ); - - $this->assertSame('Aborted', $result); - } - - public function testStreamShouldNotBeReadableIfClosed(): void - { - $eventLoop = $this->createEventLoop(); - [$streamIn, $streamOut] = $this->createStreamPair(); - - $waitSomeTicks = function () use ($eventLoop) { - yield $eventLoop->idle(); - yield $eventLoop->idle(); - yield $eventLoop->idle(); - - return 'Aborted'; - }; - - // If stream is closed, the promise will never be resolved - fclose($streamOut); - $result = $eventLoop->wait( - $eventLoop->promiseRace( - $eventLoop->async($waitSomeTicks()), - $eventLoop->readable($streamOut) - ) - ); - - $this->assertSame('Aborted', $result); - } }