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 317b031 commit 77b5d09
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 2 additions & 7 deletions phpunit.xml.dist → phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
<coverage/>
<testsuites>
<testsuite name="Unit tests">
<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>
<file>tests/suites/client/HandshakeTest.php</file>

</testsuite>
</testsuites>
<source>
Expand Down
5 changes: 5 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public function isRunning(): bool
*/
public function isConnected(): bool
{
echo "Client.isConnected \n";
return $this->connection && $this->connection->isConnected();
}

Expand Down Expand Up @@ -371,6 +372,7 @@ public function isWritable(): bool
*/
public function connect(): void
{
echo "Client.connect {$this->socketUri}\n";
$this->disconnect();
$this->streams = $this->streamFactory->createStreamCollection();

Expand Down Expand Up @@ -402,6 +404,7 @@ public function connect(): void
$this->connection->addMiddleware($middleware);
}

echo "Client.connect > isConnected\n";
if (!$this->isConnected()) {
$error = "Invalid stream on \"{$host_uri}\".";
$this->logger->error("[client] {$error}");
Expand All @@ -416,6 +419,7 @@ public function connect(): void
if ($uri = $e->getUri()) {
$this->socketUri = $uri;
}
$this->disconnect();
$this->connect();
return;
}
Expand All @@ -428,6 +432,7 @@ public function connect(): void
*/
public function disconnect(): void
{
echo "Client.disconnect \n";
if ($this->isConnected()) {
$this->connection->disconnect();
$this->logger->info('[client] Client disconnected');
Expand Down
2 changes: 2 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Connection implements LoggerAwareInterface, Stringable

public function __construct(SocketStream $stream, bool $pushMasked, bool $pullMaskedRequired, bool $ssl = false)
{
echo "Connection.__construct\n";
$this->stream = $stream;
$this->httpHandler = new HttpHandler($this->stream, $ssl);
$this->messageHandler = new MessageHandler(new FrameHandler($this->stream, $pushMasked, $pullMaskedRequired));
Expand All @@ -79,6 +80,7 @@ public function __construct(SocketStream $stream, bool $pushMasked, bool $pullMa

public function __destruct()
{
echo "Connection.__destruct\n";
if ($this->isConnected()) {
$this->stream->close();
}
Expand Down
11 changes: 6 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 testHandshakeResponse(): void
public function xxxtestHandshakeResponse(): void
{
// Creating client
$this->expectStreamFactory();
Expand All @@ -79,7 +79,7 @@ public function testHandshakeResponse(): void
unset($client);
}

public function testHandshakeConnectionFailure(): void
public function xxxtestHandshakeConnectionFailure(): void
{
$this->expectStreamFactory();
$client = new Client('ws://localhost:8000/my/mock/path');
Expand All @@ -101,7 +101,7 @@ public function testHandshakeConnectionFailure(): void
unset($client);
}

public function testHandshakeUpgradeStatusFailure(): void
public function xxxtestHandshakeUpgradeStatusFailure(): void
{
$this->expectStreamFactory();
$client = new Client('ws://localhost:8000/my/mock/path');
Expand All @@ -121,7 +121,7 @@ public function testHandshakeUpgradeStatusFailure(): void
unset($client);
}

public function testHandshakeUpgradeHeadersFailure(): void
public function xxxtestHandshakeUpgradeHeadersFailure(): void
{
$this->expectStreamFactory();
$client = new Client('ws://localhost:8000/my/mock/path');
Expand All @@ -141,7 +141,7 @@ public function testHandshakeUpgradeHeadersFailure(): void
unset($client);
}

public function testHandshakeUpgradeKeyFailure(): void
public function xxxtestHandshakeUpgradeKeyFailure(): void
{
$this->expectStreamFactory();
$client = new Client('ws://localhost:8000/my/mock/path');
Expand Down Expand Up @@ -175,6 +175,7 @@ public function testHandshakeReconnect(): void
});
$this->expectSocketStreamIsConnected();
$this->expectSocketStreamClose();
$this->expectSocketStreamIsConnected();
$this->expectWsClientConnect(host: 'redirect.to', port: 8001);
$this->expectWsClientPerformHandshake(path: '/new/target', host: 'redirect.to:8001');
$this->expectSocketStreamIsConnected();
Expand Down

0 comments on commit 77b5d09

Please sign in to comment.