PersonalBatchTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Test\Unit;
  3. use RuntimeException;
  4. use Test\TestCase;
  5. class PersonalBatchTest extends TestCase
  6. {
  7. /**
  8. * personal
  9. *
  10. * @var Web3\Personal
  11. */
  12. protected $personal;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->personal = $this->web3->personal;
  22. }
  23. /**
  24. * testBatch
  25. *
  26. * @return void
  27. */
  28. public function testBatch()
  29. {
  30. $personal = $this->personal;
  31. $personal->batch(true);
  32. $personal->listAccounts();
  33. $personal->newAccount('123456');
  34. $personal->provider->execute(function ($err, $data) {
  35. if ($err !== null) {
  36. return $this->assertTrue($err !== null);
  37. }
  38. $this->assertTrue(is_array($data[0]));
  39. $this->assertTrue(is_string($data[1]));
  40. });
  41. }
  42. /**
  43. * testWrongParam
  44. *
  45. * @return void
  46. */
  47. public function testWrongParam()
  48. {
  49. $this->expectException(RuntimeException::class);
  50. $personal = $this->personal;
  51. $personal->batch(true);
  52. $personal->listAccounts();
  53. $personal->newAccount($personal);
  54. $personal->provider->execute(function ($err, $data) {
  55. if ($err !== null) {
  56. return $this->fail($err->getMessage());
  57. }
  58. $this->assertTrue(is_string($data[0]));
  59. $this->assertEquals($data[1], $this->testHash);
  60. });
  61. }
  62. }