diff --git a/composer.json b/composer.json index ecce7c34..a3c4cf60 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require-dev": { "clue/block-react": "^1.2", - "phpunit/phpunit": "^5.0 || ^4.8" + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" }, "autoload": { "psr-4": { diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 01232dba..194ed539 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -98,7 +98,6 @@ public function gettingPlaintextStuffFromEncryptedGoogleShouldNotWork() $this->assertNotRegExp('#^HTTP/1\.0#', $response); } - /** @test */ public function testConnectingFailsIfDnsUsesInvalidResolver() { $loop = Factory::create(); @@ -114,7 +113,6 @@ public function testConnectingFailsIfDnsUsesInvalidResolver() Block\await($connector->connect('google.com:80'), $loop, self::TIMEOUT); } - /** @test */ public function testConnectingFailsIfTimeoutIsTooSmall() { if (!function_exists('stream_socket_enable_crypto')) { @@ -131,7 +129,6 @@ public function testConnectingFailsIfTimeoutIsTooSmall() Block\await($connector->connect('google.com:80'), $loop, self::TIMEOUT); } - /** @test */ public function testSelfSignedRejectsIfVerificationIsEnabled() { if (!function_exists('stream_socket_enable_crypto')) { @@ -150,7 +147,6 @@ public function testSelfSignedRejectsIfVerificationIsEnabled() Block\await($connector->connect('tls://self-signed.badssl.com:443'), $loop, self::TIMEOUT); } - /** @test */ public function testSelfSignedResolvesIfVerificationIsDisabled() { if (!function_exists('stream_socket_enable_crypto')) { @@ -167,6 +163,9 @@ public function testSelfSignedResolvesIfVerificationIsDisabled() $conn = Block\await($connector->connect('tls://self-signed.badssl.com:443'), $loop, self::TIMEOUT); $conn->close(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testCancelPendingConnection() diff --git a/tests/SecureIntegrationTest.php b/tests/SecureIntegrationTest.php index 357acb65..8c9ba14d 100644 --- a/tests/SecureIntegrationTest.php +++ b/tests/SecureIntegrationTest.php @@ -51,6 +51,9 @@ public function testConnectToServer() /* @var $client ConnectionInterface */ $client->close(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testConnectToServerEmitsConnection() diff --git a/tests/ServerTest.php b/tests/ServerTest.php index 1a5d2a90..14fdb2c8 100644 --- a/tests/ServerTest.php +++ b/tests/ServerTest.php @@ -13,11 +13,13 @@ class ServerTest extends TestCase { const TIMEOUT = 0.1; - public function testCreateServer() + public function testCreateServerWithZeroPortAssignsRandomPort() { $loop = Factory::create(); $server = new Server(0, $loop); + $this->assertNotEquals(0, $server->getAddress()); + $server->close(); } /** @@ -80,7 +82,7 @@ public function testDoesNotEmitConnectionForNewConnectionToPausedServer() $server = new Server(0, $loop); $server->pause(); - + $server->on('connection', $this->expectCallableNever()); $client = stream_socket_client($server->getAddress()); diff --git a/tests/TcpConnectorTest.php b/tests/TcpConnectorTest.php index 526fb6ab..17c55240 100644 --- a/tests/TcpConnectorTest.php +++ b/tests/TcpConnectorTest.php @@ -174,20 +174,6 @@ public function connectionToInvalidSchemeShouldFailImmediately() ); } - /** @test */ - public function connectionWithInvalidContextShouldFailImmediately() - { - $this->markTestIncomplete(); - - $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); - - $connector = new TcpConnector($loop, array('bindto' => 'invalid.invalid:123456')); - $connector->connect('127.0.0.1:80')->then( - $this->expectCallableNever(), - $this->expectCallableOnce() - ); - } - /** @test */ public function cancellingConnectionShouldRejectPromise() { diff --git a/tests/TcpServerTest.php b/tests/TcpServerTest.php index d66ba6f6..72b3c28d 100644 --- a/tests/TcpServerTest.php +++ b/tests/TcpServerTest.php @@ -107,12 +107,18 @@ public function testLoopWillEndWhenServerIsClosed() $this->server = null; $this->loop->run(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testCloseTwiceIsNoOp() { $this->server->close(); $this->server->close(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testGetAddressAfterCloseReturnsNull() @@ -136,6 +142,9 @@ public function testLoopWillEndWhenServerIsClosedAfterSingleConnection() }); $this->loop->run(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testDataWillBeEmittedInMultipleChunksWhenClientSendsExcessiveAmounts() diff --git a/tests/TestCase.php b/tests/TestCase.php index 81e925d6..e87fc2f1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,8 +6,9 @@ use React\EventLoop\LoopInterface; use Clue\React\Block; use React\Promise\Promise; +use PHPUnit\Framework\TestCase as BaseTestCase; -class TestCase extends \PHPUnit_Framework_TestCase +class TestCase extends BaseTestCase { protected function expectCallableExactly($amount) { @@ -80,4 +81,21 @@ function () use ($stream) { } ), $loop, $timeout); } + + public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null) + { + if (method_exists($this, 'expectException')) { + // PHPUnit 5+ + $this->expectException($exception); + if ($exceptionMessage !== '') { + $this->expectExceptionMessage($exceptionMessage); + } + if ($exceptionCode !== null) { + $this->expectExceptionCode($exceptionCode); + } + } else { + // legacy PHPUnit 4 + parent::setExpectedException($exception, $exceptionMessage, $exceptionCode); + } + } } diff --git a/tests/UnixServerTest.php b/tests/UnixServerTest.php index 51f49601..10f7e4f6 100644 --- a/tests/UnixServerTest.php +++ b/tests/UnixServerTest.php @@ -100,12 +100,18 @@ public function testLoopWillEndWhenServerIsClosed() $this->server = null; $this->loop->run(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testCloseTwiceIsNoOp() { $this->server->close(); $this->server->close(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testGetAddressAfterCloseReturnsNull() @@ -129,6 +135,9 @@ public function testLoopWillEndWhenServerIsClosedAfterSingleConnection() }); $this->loop->run(); + + // if we reach this, then everything is good + $this->assertNull(null); } public function testDataWillBeEmittedInMultipleChunksWhenClientSendsExcessiveAmounts() @@ -164,9 +173,6 @@ public function testDataWillBeEmittedInMultipleChunksWhenClientSendsExcessiveAmo $this->assertEquals($bytes, $received); } - /** - * @covers React\EventLoop\StreamSelectLoop::tick - */ public function testConnectionDoesNotEndWhenClientDoesNotClose() { $client = stream_socket_client($this->uds); @@ -181,7 +187,6 @@ public function testConnectionDoesNotEndWhenClientDoesNotClose() } /** - * @covers React\EventLoop\StreamSelectLoop::tick * @covers React\Socket\Connection::end */ public function testConnectionDoesEndWhenClientCloses() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy