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.

36 lines
1.1 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/NotEmptyValidator.php';
  14. class NotEmptyValidatorTest extends PHPUnit_Framework_TestCase
  15. {
  16. public function testValidator()
  17. {
  18. $validator = new NotEmptyValidator();
  19. $this->assertFalse($validator->isValid(''));
  20. $this->assertTrue($validator->isValid('token'));
  21. $this->assertTrue($validator->isValid(1212));
  22. $this->assertTrue($validator->isValid(array(1,2,2)));
  23. $this->assertFalse($validator->isValid(array()));
  24. $this->assertNotEmpty($validator->getMessage());
  25. }
  26. public function testEmptyValue()
  27. {
  28. $validator = new NotEmptyValidator(null);
  29. $this->assertFalse($validator->isValid(null));
  30. }
  31. }