PostFormatterTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Formatters\PostFormatter;
  5. class PostFormatterTest extends TestCase
  6. {
  7. /**
  8. * formatter
  9. *
  10. * @var \Web3\Formatters\PostFormatter
  11. */
  12. protected $formatter;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->formatter = new PostFormatter;
  22. }
  23. /**
  24. * testFormat
  25. *
  26. * @return void
  27. */
  28. public function testFormat()
  29. {
  30. $formatter = $this->formatter;
  31. $post= $formatter->format([
  32. 'from' => "0x776869737065722d636861742d636c69656e74",
  33. 'to' => "0x4d5a695276454c39425154466b61693532",
  34. 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
  35. 'payload' => "0x7b2274797065223a226d6",
  36. 'priority' => 12,
  37. 'ttl' => 50,
  38. ]);
  39. $this->assertEquals($post, [
  40. 'from' => "0x776869737065722d636861742d636c69656e74",
  41. 'to' => "0x4d5a695276454c39425154466b61693532",
  42. 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
  43. 'payload' => "0x7b2274797065223a226d6",
  44. 'priority' => '0xc',
  45. 'ttl' => '0x32',
  46. ]);
  47. $post= $formatter->format([
  48. 'from' => "0x776869737065722d636861742d636c69656e74",
  49. 'to' => "0x4d5a695276454c39425154466b61693532",
  50. 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
  51. 'payload' => "0x7b2274797065223a226d6",
  52. 'priority' => '0xab',
  53. 'ttl' => '0xcc',
  54. ]);
  55. $this->assertEquals($post, [
  56. 'from' => "0x776869737065722d636861742d636c69656e74",
  57. 'to' => "0x4d5a695276454c39425154466b61693532",
  58. 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
  59. 'payload' => "0x7b2274797065223a226d6",
  60. 'priority' => '0xab',
  61. 'ttl' => '0xcc',
  62. ]);
  63. }
  64. }