PriorityTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. require_once 'PHPUnit/Framework/TestCase.php';
  3. require_once 'Zend/Validate/Sitemap/Priority.php';
  4. /**
  5. * Tests Zend_Validate_Sitemap_Priority
  6. *
  7. */
  8. class Zend_Validate_Sitemap_PriorityTest extends PHPUnit_Framework_TestCase
  9. {
  10. /**
  11. * Validator
  12. *
  13. * @var Zend_Validate_Sitemap_Priority
  14. */
  15. protected $_validator;
  16. /**
  17. * Prepares the environment before running a test
  18. */
  19. protected function setUp()
  20. {
  21. $this->_validator = new Zend_Validate_Sitemap_Priority();
  22. }
  23. /**
  24. * Cleans up the environment after running a test
  25. */
  26. protected function tearDown()
  27. {
  28. $this->_validator = null;
  29. }
  30. /**
  31. * Tests valid priorities
  32. *
  33. */
  34. public function testValidPriorities()
  35. {
  36. $values = array(
  37. '0.0', '0.1', '0.2', '0.3', '0.4', '0.5',
  38. '0.6', '0.7', '0.8', '0.9', '1.0', '0.99',
  39. 0.1, 0.6667, 0.0001, 0.4, 0, 1, .35
  40. );
  41. foreach ($values as $value) {
  42. $this->assertSame(true, $this->_validator->isValid($value));
  43. }
  44. }
  45. /**
  46. * Tests invalid priorities
  47. *
  48. */
  49. public function testInvalidPriorities()
  50. {
  51. $values = array(
  52. 'alwayz', '_hourly', 'Daily', 'wEekly',
  53. 'mönthly ', ' yearly ', 'never ', 'rofl',
  54. '0,0', '1.1', '02', '3', '01.4', '0.f',
  55. 1.1, -0.001, 1.0001
  56. );
  57. foreach ($values as $value) {
  58. $this->assertSame(false, $this->_validator->isValid($value));
  59. }
  60. }
  61. }