diff --git a/test/unit/ShhApiTest.php b/test/unit/ShhApiTest.php index 602928f..c1a3f34 100644 --- a/test/unit/ShhApiTest.php +++ b/test/unit/ShhApiTest.php @@ -3,7 +3,9 @@ namespace Test\Unit; use RuntimeException; +use InvalidArgumentException; use Test\TestCase; +use Web3\Shh; class ShhApiTest extends TestCase { @@ -463,4 +465,36 @@ class ShhApiTest extends TestCase // $this->assertTrue(true); // }); // } + /** + * testUnallowedMethod + * + * @return void + */ + public function testUnallowedMethod() + { + $this->expectException(RuntimeException::class); + + $shh = $this->shh; + + $shh->hello(function ($err, $hello) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + $this->assertTrue(true); + }); + } + + /** + * testWrongCallback + * + * @return void + */ + public function testWrongCallback() + { + $this->expectException(InvalidArgumentException::class); + + $shh = $this->shh; + + $shh->version(); + } } \ No newline at end of file diff --git a/test/unit/ShhTest.php b/test/unit/ShhTest.php index f000350..10cca8c 100644 --- a/test/unit/ShhTest.php +++ b/test/unit/ShhTest.php @@ -7,6 +7,7 @@ use Test\TestCase; use Web3\Providers\HttpProvider; use Web3\RequestManagers\RequestManager; use Web3\RequestManagers\HttpRequestManager; +use Web3\Shh; class ShhTest extends TestCase { @@ -36,7 +37,7 @@ class ShhTest extends TestCase */ public function testInstance() { - $shh = $this->shh; + $shh = new Shh($this->testHost); $this->assertTrue($shh->provider instanceof HttpProvider); $this->assertTrue($shh->provider->requestManager instanceof RequestManager); @@ -54,5 +55,22 @@ class ShhTest extends TestCase $shh->provider = new HttpProvider($requestManager); $this->assertEquals($shh->provider->requestManager->host, 'http://localhost:8545'); + + $shh->provider = null; + + $this->assertEquals($shh->provider->requestManager->host, 'http://localhost:8545'); + } + + /** + * testCallThrowRuntimeException + * + * @return void + */ + public function testCallThrowRuntimeException() + { + $this->expectException(RuntimeException::class); + + $shh = new Shh(null); + $shh->post([]); } } \ No newline at end of file