LessThanTest.php 2.5 KB

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