diff --git a/test/unit/Web3ApiTest.php b/test/unit/Web3ApiTest.php index a46f504..4b365c3 100644 --- a/test/unit/Web3ApiTest.php +++ b/test/unit/Web3ApiTest.php @@ -3,6 +3,7 @@ namespace Test\Unit; use RuntimeException; +use InvalidArgumentException; use Test\TestCase; class Web3ApiTest extends TestCase @@ -113,4 +114,18 @@ class Web3ApiTest extends TestCase $this->assertTrue(true); }); } + + /** + * testWrongCallback + * + * @return void + */ + public function testWrongCallback() + { + $this->expectException(InvalidArgumentException::class); + + $web3 = $this->web3; + + $web3->sha3('hello world'); + } } \ No newline at end of file diff --git a/test/unit/Web3Test.php b/test/unit/Web3Test.php index aee0a4c..bbd05eb 100644 --- a/test/unit/Web3Test.php +++ b/test/unit/Web3Test.php @@ -49,7 +49,8 @@ class Web3Test extends TestCase */ public function testInstance() { - $web3 = $this->web3; + $requestManager = new HttpRequestManager('http://localhost:8545'); + $web3 = new Web3(new HttpProvider($requestManager)); $this->assertTrue($web3->provider instanceof HttpProvider); $this->assertTrue($web3->provider->requestManager instanceof RequestManager); @@ -72,5 +73,21 @@ class Web3Test extends TestCase $web3->provider = new HttpProvider($requestManager); $this->assertEquals($web3->provider->requestManager->host, 'http://localhost:8545'); + + $web3->provider = null; + $this->assertEquals($web3->provider->requestManager->host, 'http://localhost:8545'); + } + + /** + * testCallThrowRuntimeException + * + * @return void + */ + public function testCallThrowRuntimeException() + { + $this->expectException(RuntimeException::class); + + $web3 = new Web3(null); + $web3->sha3('hello world'); } } \ No newline at end of file