ShhTest.php 1.5 KB

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