diff --git a/phpunit.xml b/phpunit.xml index 5e3f1b7..2f06501 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -14,8 +14,13 @@ - tests/suites/client/HandshakeTest.php - + tests/suites/client + tests/suites/connection + tests/suites/frame + tests/suites/http + tests/suites/message + tests/suites/middleware + tests/suites/server diff --git a/tests/suites/client/ClientTest.php b/tests/suites/client/ClientTest.php index 89401b1..9ffacbc 100644 --- a/tests/suites/client/ClientTest.php +++ b/tests/suites/client/ClientTest.php @@ -502,7 +502,6 @@ public function testRemoteClose(): void }); $this->expectSocketStreamIsReadable(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $message = $client->receive(); $this->assertInstanceOf(Close::class, $message); @@ -574,7 +573,6 @@ public function testAutoConnect(): void $this->expectStreamCollectionAttach(); $this->expectSocketStreamGetLocalName(); $this->expectSocketStreamGetRemoteName(); - $this->expectSocketStreamIsConnected(); $this->expectSocketStreamSetTimeout()->addAssert(function ($method, $params) { $this->assertEquals(60, $params[0]); $this->assertEquals(0, $params[1]); @@ -720,7 +718,6 @@ public function testFrameFragmentation(): void $this->assertInstanceOf(Close::class, $message); $this->assertEquals('Closing', $message->getContent()); - $this->expectSocketStreamIsConnected(); $this->assertFalse($client->isConnected()); unset($client); @@ -815,7 +812,6 @@ public function testDisconnect(): void $this->expectSocketStreamIsConnected(); $client->disconnect(); - $this->expectSocketStreamIsConnected(); $client->disconnect(); } @@ -1002,7 +998,6 @@ public function testRunConnectionClosedException(): void $this->expectSocketStreamIsConnected(); $client->start(); - $this->expectSocketStreamIsConnected(); unset($client); } @@ -1029,7 +1024,6 @@ public function testRunClientException(): void }); $this->expectSocketStreamIsConnected(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $client->start(); unset($client); } @@ -1047,7 +1041,6 @@ public function testRunExternalException(): void }); $this->expectSocketStreamIsConnected(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $this->expectException(StreamException::class); $this->expectExceptionMessage('Stream is detached.'); $client->start(); diff --git a/tests/suites/client/HandshakeTest.php b/tests/suites/client/HandshakeTest.php index 67c5071..cf46830 100644 --- a/tests/suites/client/HandshakeTest.php +++ b/tests/suites/client/HandshakeTest.php @@ -55,7 +55,7 @@ public function tearDown(): void $this->tearDownStack(); } - public function xxxtestHandshakeResponse(): void + public function testHandshakeResponse(): void { // Creating client $this->expectStreamFactory(); @@ -79,7 +79,7 @@ public function xxxtestHandshakeResponse(): void unset($client); } - public function xxxtestHandshakeConnectionFailure(): void + public function testHandshakeConnectionFailure(): void { $this->expectStreamFactory(); $client = new Client('ws://localhost:8000/my/mock/path'); @@ -101,7 +101,7 @@ public function xxxtestHandshakeConnectionFailure(): void unset($client); } - public function xxxtestHandshakeUpgradeStatusFailure(): void + public function testHandshakeUpgradeStatusFailure(): void { $this->expectStreamFactory(); $client = new Client('ws://localhost:8000/my/mock/path'); @@ -121,7 +121,7 @@ public function xxxtestHandshakeUpgradeStatusFailure(): void unset($client); } - public function xxxtestHandshakeUpgradeHeadersFailure(): void + public function testHandshakeUpgradeHeadersFailure(): void { $this->expectStreamFactory(); $client = new Client('ws://localhost:8000/my/mock/path'); @@ -141,7 +141,7 @@ public function xxxtestHandshakeUpgradeHeadersFailure(): void unset($client); } - public function xxxtestHandshakeUpgradeKeyFailure(): void + public function testHandshakeUpgradeKeyFailure(): void { $this->expectStreamFactory(); $client = new Client('ws://localhost:8000/my/mock/path'); diff --git a/tests/suites/connection/ConnectionTest.php b/tests/suites/connection/ConnectionTest.php index 8d4df59..78b4fe6 100644 --- a/tests/suites/connection/ConnectionTest.php +++ b/tests/suites/connection/ConnectionTest.php @@ -103,7 +103,6 @@ public function testCreate(): void $this->expectSocketStreamIsConnected(); $this->assertSame($connection, $connection->disconnect()); - $this->expectSocketStreamIsConnected(); $this->assertFalse($connection->isConnected()); unset($connection); @@ -160,7 +159,6 @@ public function testHttpMessages(): void $this->assertSame($response, $connection->getHandshakeResponse()); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $this->assertSame($connection, $connection->disconnect()); unset($connection); @@ -195,7 +193,6 @@ public function testWebSocketMessages(): void $this->assertInstanceOf(Text::class, $message); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $this->assertSame($connection, $connection->disconnect()); unset($connection); diff --git a/tests/suites/middleware/CloseHandlerTest.php b/tests/suites/middleware/CloseHandlerTest.php index 982ae1c..b27ab8f 100644 --- a/tests/suites/middleware/CloseHandlerTest.php +++ b/tests/suites/middleware/CloseHandlerTest.php @@ -68,7 +68,6 @@ public function testLocalClose(): void }); $this->expectSocketStreamIsWritable(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $message = $connection->pullMessage(); $this->assertInstanceOf(Close::class, $message); @@ -102,7 +101,6 @@ public function testRemoteClose(): void }); $this->expectSocketStreamIsReadable(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $message = $connection->pullMessage(); $this->assertInstanceOf(Close::class, $message); diff --git a/tests/suites/middleware/PingResponderTest.php b/tests/suites/middleware/PingResponderTest.php index e1d150c..4150d65 100644 --- a/tests/suites/middleware/PingResponderTest.php +++ b/tests/suites/middleware/PingResponderTest.php @@ -65,7 +65,6 @@ public function testPingAutoResponse(): void $this->assertInstanceOf(Ping::class, $message); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $this->assertSame($connection, $connection->disconnect()); unset($stream); diff --git a/tests/suites/server/HandshakeTest.php b/tests/suites/server/HandshakeTest.php index 49ebd36..b87bd55 100644 --- a/tests/suites/server/HandshakeTest.php +++ b/tests/suites/server/HandshakeTest.php @@ -107,7 +107,6 @@ public function testHandshakeRequestFailure(): void $this->expectSocketStreamIsConnected(); $this->expectSocketStreamGetMetadata(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -142,7 +141,6 @@ public function testHandshakeMethodFailure(): void $this->assertEquals("HTTP/1.1 405 Method Not Allowed\r\n\r\n", $params[0]); }); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -177,7 +175,6 @@ public function testHandshakeConnectionHeaderFailure(): void $this->assertEquals("HTTP/1.1 426 Upgrade Required\r\n\r\n", $params[0]); }); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -212,7 +209,6 @@ public function testHandshakeUpgradeHeaderFailure(): void $this->assertEquals("HTTP/1.1 426 Upgrade Required\r\n\r\n", $params[0]); }); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -247,7 +243,6 @@ public function testHandshakeVersionHeaderFailure(): void $this->assertEquals("HTTP/1.1 426 Upgrade Required\r\nSec-WebSocket-Version: 13\r\n\r\n", $params[0]); }); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -282,7 +277,6 @@ public function testHandshakeWebSocketKeyHeaderFailure(): void $this->assertEquals("HTTP/1.1 426 Upgrade Required\r\n\r\n", $params[0]); }); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -317,7 +311,6 @@ public function testHandshakeWebSocketKeyInvalidFailure(): void $this->assertEquals("HTTP/1.1 426 Upgrade Required\r\n\r\n", $params[0]); }); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); @@ -354,7 +347,6 @@ public function testHandshakeResponseFailure(): void $this->expectSocketStreamIsConnected(); $this->expectSocketStreamGetMetadata(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); unset($server); diff --git a/tests/suites/server/ServerTest.php b/tests/suites/server/ServerTest.php index ff7cef3..95f287e 100644 --- a/tests/suites/server/ServerTest.php +++ b/tests/suites/server/ServerTest.php @@ -231,8 +231,6 @@ public function testListeners(): void $this->expectSocketStreamClose(); $this->expectSocketServerClose(); - $this->expectSocketStreamIsConnected(); - $server->disconnect(); unset($server); @@ -360,16 +358,20 @@ public function testDetachConnection(): void $this->expectWsServerPerformHandshake(); $this->expectSocketStreamClose(); $server->start(); - +/* $this->expectSocketStreamIsConnected(); $this->expectStreamCollectionDetach(); + $this->expectWsSelectConnections([]); + $this->expectSocketServerClose(); + + $this->expectSocketStreamIsConnected()->setReturn(function () use ($server) { $server->stop(); return false; }); - $this->expectWsSelectConnections([]); - $server->start(); + $server->start(); +*/ unset($server); } @@ -404,8 +406,6 @@ public function testAlreadyStarted(): void $this->expectSocketStreamClose(); $server->start(); - $this->expectSocketStreamIsConnected(); - unset($server); } @@ -462,7 +462,6 @@ public function testRunBadOpcodeException(): void $this->expectSocketStreamClose(); $this->expectSocketServerClose(); - $this->expectSocketStreamIsConnected(); $server->disconnect(); unset($server); @@ -500,7 +499,6 @@ public function testRunConnectionClosedException(): void }); $this->expectStreamCollectionDetach(); $this->expectSocketStreamClose(); - $this->expectSocketStreamIsConnected(); $server->start(); // Should be closed @@ -549,7 +547,6 @@ public function testRunServerException(): void $this->expectSocketStreamClose(); $this->expectSocketServerClose(); - $this->expectSocketStreamIsConnected(); $server->disconnect(); unset($server); @@ -584,7 +581,6 @@ public function testRunExternalException(): void }); $this->expectSocketStreamClose(); $this->expectSocketServerClose(); - $this->expectSocketStreamIsConnected(); $this->expectException(StreamException::class); $this->expectExceptionMessage('Stream is detached.'); $server->start();