From 34f835f15e32e8ed56adb7958dc5571676da8759 Mon Sep 17 00:00:00 2001 From: huangzhhui Date: Mon, 10 Aug 2020 00:32:50 +0800 Subject: [PATCH] Add integration test to make sure Jet works --- src/jet/tests/IntegrationTest.php | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/jet/tests/IntegrationTest.php diff --git a/src/jet/tests/IntegrationTest.php b/src/jet/tests/IntegrationTest.php new file mode 100644 index 000000000..349598797 --- /dev/null +++ b/src/jet/tests/IntegrationTest.php @@ -0,0 +1,60 @@ +markTestSkipped('This test needs a complete RPC Server.'); + } + + public function testJsonrpc() + { + $protocol = 'jsonrpc'; + ProtocolManager::register($protocol, [ + ProtocolManager::TRANSPORTER => new StreamSocketTransporter(), + ProtocolManager::PACKER => new JsonEofPacker(), + ProtocolManager::PATH_GENERATOR => new PathGenerator(), + ProtocolManager::DATA_FORMATTER => new DataFormatter(), + ]); + $service = 'CalculatorService'; + ServiceManager::register($service, $protocol, [ + ServiceManager::NODES => [ + [$this->host, $this->port], + ], + ]); + $clientFactory = new ClientFactory(); + $client = $clientFactory->create($service, $protocol); + $result = $client->add($a = 1, $b = 2); + $this->assertSame($a + $b, $result); + $result = $client->add($a = -20, $b = -10); + $this->assertSame($a + $b, $result); + } +}