Add Personal tests.

This commit is contained in:
sc0Vu 2018-02-07 11:40:51 +08:00
parent 82087c92ce
commit aead0b3c75
2 changed files with 34 additions and 1 deletions

View File

@ -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');
}
}

View File

@ -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('');
}
}