From 1cd9e213355d23a525f9ac766c8627e0f13c5fc2 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Mon, 16 Aug 2021 11:56:25 +0200 Subject: [PATCH] Simplify usage by supporting new Socket API --- README.md | 2 +- composer.json | 2 +- tests/FactoryIntegrationTest.php | 38 ++++++++++++++++---------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 58e0c6c..9735206 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ proxy servers etc.), you can explicitly pass a custom instance of the [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface): ```php -$connector = new React\Socket\Connector(null, array( +$connector = new React\Socket\Connector(array( 'dns' => '127.0.0.1', 'tcp' => array( 'bindto' => '192.168.10.1:0' diff --git a/composer.json b/composer.json index 3ffa239..c0a7224 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "clue/qdatastream": "^0.8", "react/event-loop": "^1.2", "react/promise": "~2.0|~1.1", - "react/socket": "^1.8", + "react/socket": "^1.9", "react/stream": "^1.2" }, "require-dev": { diff --git a/tests/FactoryIntegrationTest.php b/tests/FactoryIntegrationTest.php index d003bf0..3a1b67a 100644 --- a/tests/FactoryIntegrationTest.php +++ b/tests/FactoryIntegrationTest.php @@ -7,14 +7,14 @@ use Clue\React\Quassel\Factory; use Clue\React\Quassel\Io\Protocol; use React\EventLoop\Loop; -use React\Socket\Server; +use React\Socket\SocketServer; use React\Socket\ConnectionInterface; class FactoryIntegrationTest extends TestCase { public function testCreateClientCreatesConnection() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', $this->expectCallableOnce()); $uri = str_replace('tcp://', '', $server->getAddress()); @@ -26,7 +26,7 @@ public function testCreateClientCreatesConnection() public function testCreateClientSendsProbeOverConnection() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $data = $this->expectCallableOnceWith("\x42\xb3\x3f\x00" . "\x00\x00\x00\x02" . "\x80\x00\x00\x01"); $server->on('connection', function (ConnectionInterface $conn) use ($data) { @@ -42,7 +42,7 @@ public function testCreateClientSendsProbeOverConnection() public function testCreateClientResolvesIfServerRespondsWithProbeResponse() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->on('data', function () use ($conn) { @@ -62,7 +62,7 @@ public function testCreateClientResolvesIfServerRespondsWithProbeResponse() public function testCreateClientCreatesSecondConnectionWithoutProbeIfConnectionClosesDuringProbe() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $once = $this->expectCallableOnce(); $server->on('connection', function (ConnectionInterface $conn) use ($once) { @@ -81,7 +81,7 @@ public function testCreateClientCreatesSecondConnectionWithoutProbeIfConnectionC public function testCreateClientRejectsIfServerRespondsWithInvalidData() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->on('data', function () use ($conn) { @@ -99,7 +99,7 @@ public function testCreateClientRejectsIfServerRespondsWithInvalidData() public function testCreateClientWithAuthSendsClientInitAfterProbe() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $data = $this->expectCallableOnceWith($this->callback(function ($packet) { $data = FactoryIntegrationTest::decode($packet); @@ -123,7 +123,7 @@ public function testCreateClientWithAuthSendsClientInitAfterProbe() public function testCreateClientWithAuthRejectsIfServerClosesAfterClientInit() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->on('data', function () use ($conn) { @@ -144,7 +144,7 @@ public function testCreateClientWithAuthRejectsIfServerClosesAfterClientInit() public function testCreateClientWithAuthRejectsIfServerSendsClientInitRejectAfterClientInit() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->once('data', function () use ($conn) { @@ -170,7 +170,7 @@ public function testCreateClientWithAuthRejectsIfServerSendsClientInitRejectAfte public function testCreateClientWithAuthRejectsIfServerSendsUnknownMessageAfterClientInit() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->once('data', function () use ($conn) { @@ -196,7 +196,7 @@ public function testCreateClientWithAuthRejectsIfServerSendsUnknownMessageAfterC public function testCreateClientWithAuthRejectsIfServerSendsInvalidTruncatedResponseAfterClientInit() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->once('data', function () use ($conn) { @@ -217,7 +217,7 @@ public function testCreateClientWithAuthRejectsIfServerSendsInvalidTruncatedResp public function testCreateClientWithAuthRejectsIfServerSendsClientInitAckNotConfigured() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->once('data', function () use ($conn) { @@ -242,7 +242,7 @@ public function testCreateClientWithAuthRejectsIfServerSendsClientInitAckNotConf public function testCreateClientWithAuthSendsClientLoginAfterClientInit() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); // expect login packet $data = $this->expectCallableOnceWith($this->callback(function ($packet) { @@ -277,7 +277,7 @@ public function testCreateClientWithAuthSendsClientLoginAfterClientInit() public function testCreateClientRespondsWithHeartBeatResponseAfterHeartBeatRequest() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); // expect heartbeat response packet $data = $this->expectCallableOnceWith($this->callback(function ($packet) { @@ -316,7 +316,7 @@ public function testCreateClientRespondsWithHeartBeatResponseAfterHeartBeatReque public function testCreateClientDoesNotRespondWithHeartBeatResponseIfPongIsDisabled() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); // expect no message in response $data = $this->expectCallableNever(); @@ -350,7 +350,7 @@ public function testCreateClientDoesNotRespondWithHeartBeatResponseIfPongIsDisab public function testCreateClientSendsHeartBeatRequestAtInterval() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); // expect heartbeat response packet $data = $this->expectCallableOnceWith($this->callback(function ($packet) { @@ -381,7 +381,7 @@ public function testCreateClientSendsHeartBeatRequestAtInterval() public function testCreateClientSendsNoHeartBeatRequestIfServerKeepsSendingMessages() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); // expect heartbeat response packet $data = $this->expectCallableNever(); @@ -412,7 +412,7 @@ public function testCreateClientSendsNoHeartBeatRequestIfServerKeepsSendingMessa public function testCreateClientClosesWithErrorIfServerDoesNotRespondToHeartBeatRequests() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); $server->on('connection', function (ConnectionInterface $conn) { $conn->once('data', function () use ($conn) { @@ -433,7 +433,7 @@ public function testCreateClientClosesWithErrorIfServerDoesNotRespondToHeartBeat public function testCreateClientSendsNoHeartBeatRequestIfPingIsDisabled() { - $server = new Server(0); + $server = new SocketServer('127.0.0.1:0'); // expect heartbeat response packet $data = $this->expectCallableNever();