QuantityValidatorTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Validators\QuantityValidator;
  5. class QuantityValidatorTest extends TestCase
  6. {
  7. /**
  8. * validator
  9. *
  10. * @var \Web3\Validators\QuantityValidator
  11. */
  12. protected $validator;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->validator = new QuantityValidator;
  22. }
  23. /**
  24. * testValidate
  25. *
  26. * @return void
  27. */
  28. public function testValidate()
  29. {
  30. $validator = $this->validator;
  31. $this->assertEquals(false, $validator->validate('0Xca35b7d915458ef540ade6068dfe2f44e8fa733c'));
  32. $this->assertEquals(false, $validator->validate('0XCA35B7D915458EF540ADE6068DFE2F44E8FA733C'));
  33. $this->assertEquals(false, $validator->validate('CA35B7D915458EF540ADE6068DFE2F44E8FA733C'));
  34. $this->assertEquals(false, $validator->validate('1234'));
  35. $this->assertEquals(false, $validator->validate('abcd'));
  36. $this->assertEquals(true, $validator->validate(1234));
  37. $this->assertEquals(true, $validator->validate(0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C));
  38. $this->assertEquals(true, $validator->validate('0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C'));
  39. $this->assertEquals(true, $validator->validate('0xeb0b54d62ec3f561c2eebdaebd92432126f0817579c102b062d1a6c1f2ed83e8'));
  40. $this->assertEquals(true, $validator->validate('0xeb0b54D62ec3f561C2eebdaebd92432126F0817579c102b062d1a6c1f2ed83e8121233'));
  41. }
  42. }