PriorityTest.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Translate
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once 'PHPUnit/Framework/TestCase.php';
  23. require_once 'Zend/Validate/Sitemap/Priority.php';
  24. /**
  25. * Tests Zend_Validate_Sitemap_Priority
  26. *
  27. * @category Zend
  28. * @package Zend_Validate
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Validate
  33. */
  34. class Zend_Validate_Sitemap_PriorityTest extends PHPUnit_Framework_TestCase
  35. {
  36. /**
  37. * Validator
  38. *
  39. * @var Zend_Validate_Sitemap_Priority
  40. */
  41. protected $_validator;
  42. /**
  43. * Prepares the environment before running a test
  44. */
  45. protected function setUp()
  46. {
  47. $this->_validator = new Zend_Validate_Sitemap_Priority();
  48. }
  49. /**
  50. * Cleans up the environment after running a test
  51. */
  52. protected function tearDown()
  53. {
  54. $this->_validator = null;
  55. }
  56. /**
  57. * Tests valid priorities
  58. *
  59. */
  60. public function testValidPriorities()
  61. {
  62. $values = array(
  63. '0.0', '0.1', '0.2', '0.3', '0.4', '0.5',
  64. '0.6', '0.7', '0.8', '0.9', '1.0', '0.99',
  65. 0.1, 0.6667, 0.0001, 0.4, 0, 1, .35
  66. );
  67. foreach ($values as $value) {
  68. $this->assertSame(true, $this->_validator->isValid($value));
  69. }
  70. }
  71. /**
  72. * Tests invalid priorities
  73. *
  74. */
  75. public function testInvalidPriorities()
  76. {
  77. $values = array(
  78. 'alwayz', '_hourly', 'Daily', 'wEekly',
  79. 'mönthly ', ' yearly ', 'never ', 'rofl',
  80. '0,0', '1.1', '02', '3', '01.4', '0.f',
  81. 1.1, -0.001, 1.0001
  82. );
  83. foreach ($values as $value) {
  84. $this->assertSame(false, $this->_validator->isValid($value));
  85. }
  86. }
  87. }