ShhTest.php 1.2 KB

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