ChangefreqTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. require_once 'PHPUnit/Framework/TestCase.php';
  3. require_once 'Zend/Validate/Sitemap/Changefreq.php';
  4. /**
  5. * Tests Zym_Validate_Sitemap_Changefreq
  6. *
  7. */
  8. class Zend_Validate_Sitemap_ChangefreqTest extends PHPUnit_Framework_TestCase
  9. {
  10. /**
  11. * Validator
  12. *
  13. * @var Zend_Validate_Sitemap_Changefreq
  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_Changefreq();
  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 change frequencies
  32. *
  33. */
  34. public function testValidChangefreqs()
  35. {
  36. $values = array(
  37. 'always', 'hourly', 'daily', 'weekly',
  38. 'monthly', 'yearly', 'never'
  39. );
  40. foreach ($values as $value) {
  41. $this->assertSame(true, $this->_validator->isValid($value));
  42. }
  43. }
  44. /**
  45. * Tests strings that should be invalid
  46. *
  47. */
  48. public function testInvalidStrings()
  49. {
  50. $values = array(
  51. 'alwayz', '_hourly', 'Daily', 'wEekly',
  52. 'mönthly ', ' yearly ', 'never ', 'rofl',
  53. 'yesterday',
  54. );
  55. foreach ($values as $value) {
  56. $this->assertSame(false, $this->_validator->isValid($value));
  57. }
  58. }
  59. /**
  60. * Tests values that are not strings
  61. *
  62. */
  63. public function testNotString()
  64. {
  65. $values = array(
  66. 1, 1.4, null, new stdClass(), true, false
  67. );
  68. foreach ($values as $value) {
  69. $this->assertSame(false, $this->_validator->isValid($value));
  70. }
  71. }
  72. }