You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

  1. <?php
  2. /*
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage UnitTests
  7. * @since 2011-10-07
  8. *
  9. * Unit tests for RegexValdator class
  10. */
  11. require_once dirname(__FILE__) . '/../../validator/iValidator.php';
  12. require_once dirname(__FILE__) . '/../../validator/Validator.php';
  13. require_once dirname(__FILE__) . '/../../validator/EqualValidator.php';
  14. require_once dirname(__FILE__) . '/../../exception/InitializationException.php';
  15. class EqualValidatorTest extends PHPUnit_Framework_TestCase
  16. {
  17. public function testConstructor()
  18. {
  19. $validator = new EqualValidator('token');
  20. $this->assertFalse($validator->isValid('not token'));
  21. $this->assertTrue($validator->isValid('token'));
  22. }
  23. /**
  24. * @expectedException InitializationException
  25. * @expectedExceptionMessage Token not defined
  26. */
  27. public function testNullToken()
  28. {
  29. $validator = new EqualValidator(null);
  30. $validator->isValid('not token');
  31. }
  32. }