QuantityFormatterTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Formatters\QuantityFormatter;
  5. class QuantityFormatterTest extends TestCase
  6. {
  7. /**
  8. * formatter
  9. *
  10. * @var \Web3\Formatters\QuantityFormatter
  11. */
  12. protected $formatter;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->formatter = new QuantityFormatter;
  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. }
  47. }