Skip to content

Commit

Permalink
Temp test verification
Browse files Browse the repository at this point in the history
  • Loading branch information
sirn-se committed Mar 19, 2024
1 parent a4d109d commit 38c7bed
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 39 deletions.
9 changes: 7 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
<coverage/>
<testsuites>
<testsuite name="Unit tests">
<file>tests/suites/client/HandshakeTest.php</file>

<directory suffix=".php">tests/suites/client</directory>
<directory suffix=".php">tests/suites/connection</directory>
<directory suffix=".php">tests/suites/frame</directory>
<directory suffix=".php">tests/suites/http</directory>
<directory suffix=".php">tests/suites/message</directory>
<directory suffix=".php">tests/suites/middleware</directory>
<directory suffix=".php">tests/suites/server</directory>
</testsuite>
</testsuites>
<source>
Expand Down
7 changes: 0 additions & 7 deletions tests/suites/client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ public function testRemoteClose(): void
});
$this->expectSocketStreamIsReadable();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$message = $client->receive();
$this->assertInstanceOf(Close::class, $message);

Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -815,7 +812,6 @@ public function testDisconnect(): void
$this->expectSocketStreamIsConnected();
$client->disconnect();

$this->expectSocketStreamIsConnected();
$client->disconnect();
}

Expand Down Expand Up @@ -1002,7 +998,6 @@ public function testRunConnectionClosedException(): void
$this->expectSocketStreamIsConnected();
$client->start();

$this->expectSocketStreamIsConnected();
unset($client);
}

Expand All @@ -1029,7 +1024,6 @@ public function testRunClientException(): void
});
$this->expectSocketStreamIsConnected();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$client->start();
unset($client);
}
Expand All @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions tests/suites/client/HandshakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function tearDown(): void
$this->tearDownStack();
}

public function xxxtestHandshakeResponse(): void
public function testHandshakeResponse(): void
{
// Creating client
$this->expectStreamFactory();
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down
3 changes: 0 additions & 3 deletions tests/suites/connection/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public function testCreate(): void
$this->expectSocketStreamIsConnected();
$this->assertSame($connection, $connection->disconnect());

$this->expectSocketStreamIsConnected();
$this->assertFalse($connection->isConnected());

unset($connection);
Expand Down Expand Up @@ -160,7 +159,6 @@ public function testHttpMessages(): void
$this->assertSame($response, $connection->getHandshakeResponse());

$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$this->assertSame($connection, $connection->disconnect());

unset($connection);
Expand Down Expand Up @@ -195,7 +193,6 @@ public function testWebSocketMessages(): void
$this->assertInstanceOf(Text::class, $message);

$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$this->assertSame($connection, $connection->disconnect());

unset($connection);
Expand Down
2 changes: 0 additions & 2 deletions tests/suites/middleware/CloseHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public function testLocalClose(): void
});
$this->expectSocketStreamIsWritable();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$message = $connection->pullMessage();
$this->assertInstanceOf(Close::class, $message);

Expand Down Expand Up @@ -102,7 +101,6 @@ public function testRemoteClose(): void
});
$this->expectSocketStreamIsReadable();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$message = $connection->pullMessage();
$this->assertInstanceOf(Close::class, $message);

Expand Down
1 change: 0 additions & 1 deletion tests/suites/middleware/PingResponderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function testPingAutoResponse(): void
$this->assertInstanceOf(Ping::class, $message);

$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$this->assertSame($connection, $connection->disconnect());

unset($stream);
Expand Down
8 changes: 0 additions & 8 deletions tests/suites/server/HandshakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function testHandshakeRequestFailure(): void
$this->expectSocketStreamIsConnected();
$this->expectSocketStreamGetMetadata();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$server->start();

unset($server);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -354,7 +347,6 @@ public function testHandshakeResponseFailure(): void
$this->expectSocketStreamIsConnected();
$this->expectSocketStreamGetMetadata();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$server->start();

unset($server);
Expand Down
18 changes: 7 additions & 11 deletions tests/suites/server/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ public function testListeners(): void

$this->expectSocketStreamClose();
$this->expectSocketServerClose();
$this->expectSocketStreamIsConnected();

$server->disconnect();

unset($server);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -404,8 +406,6 @@ public function testAlreadyStarted(): void
$this->expectSocketStreamClose();
$server->start();

$this->expectSocketStreamIsConnected();

unset($server);
}

Expand Down Expand Up @@ -462,7 +462,6 @@ public function testRunBadOpcodeException(): void

$this->expectSocketStreamClose();
$this->expectSocketServerClose();
$this->expectSocketStreamIsConnected();
$server->disconnect();

unset($server);
Expand Down Expand Up @@ -500,7 +499,6 @@ public function testRunConnectionClosedException(): void
});
$this->expectStreamCollectionDetach();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$server->start();

// Should be closed
Expand Down Expand Up @@ -549,7 +547,6 @@ public function testRunServerException(): void

$this->expectSocketStreamClose();
$this->expectSocketServerClose();
$this->expectSocketStreamIsConnected();
$server->disconnect();

unset($server);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 38c7bed

Please sign in to comment.