OptionalQuantityFormatterTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Formatters\OptionalQuantityFormatter;
  5. class OptionalQuantityFormatterTest extends TestCase
  6. {
  7. /**
  8. * formatter
  9. *
  10. * @var \Web3\Formatters\OptionalQuantityFormatter
  11. */
  12. protected $formatter;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->formatter = new OptionalQuantityFormatter;
  22. }
  23. /**
  24. * testFormat
  25. *
  26. * @return void
  27. */
  28. public function testFormat()
  29. {
  30. $formatter = $this->formatter;
  31. $this->assertEquals('0x927c0', $formatter->format(0x0927c0));
  32. $this->assertEquals('0x927c0', $formatter->format('0x0927c0'));
  33. $this->assertEquals('0x927c0', $formatter->format('0x927c0'));
  34. $this->assertEquals('0x927c0', $formatter->format('600000'));
  35. $this->assertEquals('0x927c0', $formatter->format(600000));
  36. $this->assertEquals('0xea60', $formatter->format('0x0ea60'));
  37. $this->assertEquals('0xea60', $formatter->format('0xea60'));
  38. $this->assertEquals('0xea60', $formatter->format(0x0ea60));
  39. $this->assertEquals('0xea60', $formatter->format('60000'));
  40. $this->assertEquals('0xea60', $formatter->format(60000));
  41. $this->assertEquals('0x0', $formatter->format(0x00));
  42. $this->assertEquals('0x0', $formatter->format('0x00'));
  43. $this->assertEquals('0x0', $formatter->format('0x0'));
  44. $this->assertEquals('0x0', $formatter->format('0'));
  45. $this->assertEquals('0x0', $formatter->format(0));
  46. $this->assertEquals('latest', $formatter->format('latest'));
  47. $this->assertEquals('earliest', $formatter->format('earliest'));
  48. $this->assertEquals('pending', $formatter->format('pending'));
  49. $this->assertEquals('0x0', $formatter->format('hello'));
  50. }
  51. }