2
0

LessThanTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_Validate
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 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. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../TestHelper.php';
  26. /**
  27. * @see Zend_Validate_LessThan
  28. */
  29. require_once 'Zend/Validate/LessThan.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Validate
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Validate
  37. */
  38. class Zend_Validate_LessThanTest extends PHPUnit_Framework_TestCase
  39. {
  40. /**
  41. * Ensures that the validator follows expected behavior
  42. *
  43. * @return void
  44. */
  45. public function testBasic()
  46. {
  47. /**
  48. * The elements of each array are, in order:
  49. * - maximum
  50. * - expected validation result
  51. * - array of test input values
  52. */
  53. $valuesExpected = array(
  54. array(100, true, array(-1, 0, 0.01, 1, 99.999)),
  55. array(100, false, array(100, 100.0, 100.01)),
  56. array('a', false, array('a', 'b', 'c', 'd')),
  57. array('z', true, array('x', 'y'))
  58. );
  59. foreach ($valuesExpected as $element) {
  60. $validator = new Zend_Validate_LessThan($element[0]);
  61. foreach ($element[2] as $input) {
  62. $this->assertEquals($element[1], $validator->isValid($input));
  63. }
  64. }
  65. }
  66. /**
  67. * Ensures that getMessages() returns expected default value
  68. *
  69. * @return void
  70. */
  71. public function testGetMessages()
  72. {
  73. $validator = new Zend_Validate_LessThan(10);
  74. $this->assertEquals(array(), $validator->getMessages());
  75. }
  76. /**
  77. * Ensures that getMax() returns expected value
  78. *
  79. * @return void
  80. */
  81. public function testGetMax()
  82. {
  83. $validator = new Zend_Validate_LessThan(10);
  84. $this->assertEquals(10, $validator->getMax());
  85. }
  86. }