LastmodTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. require_once 'PHPUnit/Framework/TestCase.php';
  3. require_once 'Zend/Validate/Sitemap/Lastmod.php';
  4. /**
  5. * Tests Zym_Validate_Sitemap_Lastmod
  6. *
  7. */
  8. class Zend_Validate_Sitemap_LastmodTest extends PHPUnit_Framework_TestCase
  9. {
  10. /**
  11. * Validator
  12. *
  13. * @var Zend_Validate_Sitemap_Lastmod
  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_Lastmod();
  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. '1994-05-11T18:00:09-08:45',
  38. '1997-05-11T18:50:09+00:00',
  39. '1998-06-11T01:00:09-02:00',
  40. '1999-11-11T22:23:52+02:00',
  41. '2000-06-11',
  42. '2001-04-14',
  43. '2003-01-13',
  44. '2005-01-01',
  45. '2006-03-19',
  46. '2007-08-31',
  47. '2007-08-25'
  48. );
  49. foreach ($values as $value) {
  50. $this->assertSame(true, $this->_validator->isValid($value));
  51. }
  52. }
  53. /**
  54. * Tests strings that should be invalid
  55. *
  56. */
  57. public function testInvalidStrings()
  58. {
  59. $values = array(
  60. '1995-05-11T18:60:09-08:45',
  61. '1996-05-11T18:50:09+25:00',
  62. '2002-13-11',
  63. '2004-00-01'
  64. );
  65. foreach ($values as $value) {
  66. $this->assertSame(false, $this->_validator->isValid($value));
  67. }
  68. }
  69. /**
  70. * Tests values that are not strings
  71. *
  72. */
  73. public function testNotString()
  74. {
  75. $values = array(
  76. 1, 1.4, null, new stdClass(), true, false
  77. );
  78. foreach ($values as $value) {
  79. $this->assertSame(false, $this->_validator->isValid($value));
  80. }
  81. }
  82. }