NonceValidatorTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Test\Unit;
  3. use Test\TestCase;
  4. use Web3\Validators\NonceValidator;
  5. class NonceValidatorTest extends TestCase
  6. {
  7. /**
  8. * validator
  9. *
  10. * @var \Web3\Validators\NonceValidator
  11. */
  12. protected $validator;
  13. /**
  14. * setUp
  15. *
  16. * @return void
  17. */
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->validator = new NonceValidator;
  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('0xcA35b7D915458eF540ade6068Dfe2f44e8fA733ccA35b7D915458eF540ade6068Dfe2f44e8fA733c'));
  34. $this->assertEquals(false, $validator->validate('CA35B7D915458EF540ADE6068DFE2F44E8FA733C'));
  35. $this->assertEquals(false, $validator->validate('1234'));
  36. $this->assertEquals(false, $validator->validate('abcd'));
  37. $this->assertEquals(false, $validator->validate(0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C));
  38. $this->assertEquals(true, $validator->validate('0xCA35B7D915458EF5'));
  39. $this->assertEquals(true, $validator->validate('0xeb0b54d62ec3f561'));
  40. $this->assertEquals(true, $validator->validate('0xeb0b54D62ec3f561'));
  41. }
  42. }