AddressFormatterTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Formatters\AddressFormatter;
  5. class AddressFormatterTest extends TestCase
  6. {
  7. /**
  8. * formatter
  9. *
  10. * @var \Web3\Formatters\AddressFormatter
  11. */
  12. protected $formatter;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->formatter = new AddressFormatter;
  22. }
  23. /**
  24. * testFormat
  25. *
  26. * @return void
  27. */
  28. public function testFormat()
  29. {
  30. $formatter = $this->formatter;
  31. $address = $formatter->format('0Xca35b7d915458ef540ade6068dfe2f44e8fa733c');
  32. $this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
  33. $address = $formatter->format('0XCA35B7D915458EF540ADE6068DFE2F44E8FA733C');
  34. $this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
  35. $address = $formatter->format('0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C');
  36. $this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
  37. $address = $formatter->format('CA35B7D915458EF540ADE6068DFE2F44E8FA733C');
  38. $this->assertEquals($address, '0xca35b7d915458ef540ade6068dfe2f44e8fa733c');
  39. $address = $formatter->format('1234');
  40. $this->assertEquals($address, '0x00000000000000000000000000000000000004d2');
  41. $address = $formatter->format('abcd');
  42. $this->assertEquals($address, '0x000000000000000000000000000000000000abcd');
  43. }
  44. }