PersonalTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Test\Unit;
  3. use RuntimeException;
  4. use Test\TestCase;
  5. use Web3\Providers\HttpProvider;
  6. use Web3\Personal;
  7. class PersonalTest extends TestCase
  8. {
  9. /**
  10. * personal
  11. *
  12. * @var Web3\Personal
  13. */
  14. protected $personal;
  15. /**
  16. * setUp
  17. *
  18. * @return void
  19. */
  20. public function setUp(): void
  21. {
  22. parent::setUp();
  23. $this->personal = $this->web3->personal;
  24. }
  25. /**
  26. * testInstance
  27. *
  28. * @return void
  29. */
  30. public function testInstance()
  31. {
  32. $personal = new Personal($this->testHost);
  33. $this->assertTrue($personal->provider instanceof HttpProvider);
  34. }
  35. /**
  36. * testSetProvider
  37. *
  38. * @return void
  39. */
  40. public function testSetProvider()
  41. {
  42. $personal = $this->personal;
  43. $personal->provider = new HttpProvider('http://localhost:8545');
  44. $this->assertEquals($personal->provider->host, 'http://localhost:8545');
  45. $personal->provider = null;
  46. $this->assertEquals($personal->provider->host, 'http://localhost:8545');
  47. }
  48. /**
  49. * testCallThrowRuntimeException
  50. *
  51. * @return void
  52. */
  53. public function testCallThrowRuntimeException()
  54. {
  55. $this->expectException(RuntimeException::class);
  56. $personal = new Personal(null);
  57. $personal->newAccount('');
  58. }
  59. }