HexFormatterTest.php 896 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Formatters\HexFormatter;
  5. class HexFormatterTest extends TestCase
  6. {
  7. /**
  8. * formatter
  9. *
  10. * @var \Web3\Formatters\HexFormatter
  11. */
  12. protected $formatter;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->formatter = new HexFormatter;
  22. }
  23. /**
  24. * testFormat
  25. *
  26. * @return void
  27. */
  28. public function testFormat()
  29. {
  30. $formatter = $this->formatter;
  31. $hex = $formatter->format('ae');
  32. $this->assertEquals($hex, '0x6165');
  33. $hex = $formatter->format('0xabce');
  34. $this->assertEquals($hex, '0xabce');
  35. $hex = $formatter->format('123');
  36. $this->assertEquals($hex, '0x7b');
  37. $hex = $formatter->format(12);
  38. $this->assertEquals($hex, '0xc');
  39. }
  40. }