From aead0b3c7585a6fb4a28863307d3138d4d6d5230 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 7 Feb 2018 11:40:51 +0800 Subject: [PATCH] Add Personal tests. --- test/unit/PersonalApiTest.php | 15 +++++++++++++++ test/unit/PersonalTest.php | 20 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/unit/PersonalApiTest.php b/test/unit/PersonalApiTest.php index a082f8b..c4538e4 100644 --- a/test/unit/PersonalApiTest.php +++ b/test/unit/PersonalApiTest.php @@ -3,6 +3,7 @@ namespace Test\Unit; use RuntimeException; +use InvalidArgumentException; use Test\TestCase; class PersonalApiTest extends TestCase @@ -200,4 +201,18 @@ class PersonalApiTest extends TestCase $this->assertTrue(is_string($account)); }); } + + /** + * testWrongCallback + * + * @return void + */ + public function testWrongCallback() + { + $this->expectException(InvalidArgumentException::class); + + $personal = $this->personal; + + $personal->newAccount('123456'); + } } \ No newline at end of file diff --git a/test/unit/PersonalTest.php b/test/unit/PersonalTest.php index 8c44f4c..5a3689c 100644 --- a/test/unit/PersonalTest.php +++ b/test/unit/PersonalTest.php @@ -7,6 +7,7 @@ use Test\TestCase; use Web3\Providers\HttpProvider; use Web3\RequestManagers\RequestManager; use Web3\RequestManagers\HttpRequestManager; +use Web3\Personal; class PersonalTest extends TestCase { @@ -36,7 +37,7 @@ class PersonalTest extends TestCase */ public function testInstance() { - $personal = $this->personal; + $personal = new Personal($this->testHost); $this->assertTrue($personal->provider instanceof HttpProvider); $this->assertTrue($personal->provider->requestManager instanceof RequestManager); @@ -54,5 +55,22 @@ class PersonalTest extends TestCase $personal->provider = new HttpProvider($requestManager); $this->assertEquals($personal->provider->requestManager->host, 'http://localhost:8545'); + + $personal->provider = null; + + $this->assertEquals($personal->provider->requestManager->host, 'http://localhost:8545'); + } + + /** + * testCallThrowRuntimeException + * + * @return void + */ + public function testCallThrowRuntimeException() + { + $this->expectException(RuntimeException::class); + + $personal = new personal(null); + $personal->newAccount(''); } } \ No newline at end of file