From 65734f1d7ffc2d27370b2841b2f098775056ffd3 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Mon, 18 Dec 2017 11:39:24 +0800 Subject: [PATCH] net_version --- test/unit/NetTest.php | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 test/unit/NetTest.php diff --git a/test/unit/NetTest.php b/test/unit/NetTest.php new file mode 100644 index 0000000..3979b13 --- /dev/null +++ b/test/unit/NetTest.php @@ -0,0 +1,72 @@ +net = $this->web3->net; + } + + /** + * testVersion + * + * @return void + */ + public function testVersion() + { + $net = $this->net; + + $net->version(function ($err, $version) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($version->result)) { + $this->assertTrue(is_string($version->result)); + } else { + $this->fail($version->error->message); + } + }); + } + + /** + * testUnallowedMethod + * + * @return void + */ + public function testUnallowedMethod() + { + $this->expectException(RuntimeException::class); + + $net = $this->net; + + $net->hello(function ($err, $hello) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($hello->result)) { + $this->assertTrue(true); + } else { + $this->fail($hello->error->message); + } + }); + } +} \ No newline at end of file