ZF-5514: implemented patch and adapted test backend
[zend/radio.git] / tests / Zend / Validate / BetweenTest.php
bloba866bfe4378518bef99bf2cdbc362b0342f0edaa
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
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$
24 /**
25 * Test helper
27 require_once dirname(__FILE__) . '/../../TestHelper.php';
29 /**
30 * @see Zend_Validate_Between
32 require_once 'Zend/Validate/Between.php';
35 /**
36 * @category Zend
37 * @package Zend_Validate
38 * @subpackage UnitTests
39 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
40 * @license http://framework.zend.com/license/new-bsd New BSD License
41 * @group Zend_Validate
43 class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase
45 /**
46 * Ensures that the validator follows expected behavior
48 * @return void
50 public function testBasic()
52 /**
53 * The elements of each array are, in order:
54 * - minimum
55 * - maximum
56 * - inclusive
57 * - expected validation result
58 * - array of test input values
60 $valuesExpected = array(
61 array(1, 100, true, true, array(1, 10, 100)),
62 array(1, 100, true, false, array(0, 0.99, 100.01, 101)),
63 array(1, 100, false, false, array(0, 1, 100, 101)),
64 array('a', 'z', true, true, array('a', 'b', 'y', 'z')),
65 array('a', 'z', false, false, array('!', 'a', 'z'))
67 foreach ($valuesExpected as $element) {
68 $validator = new Zend_Validate_Between(array('min' => $element[0], 'max' => $element[1], 'inclusive' => $element[2]));
69 foreach ($element[4] as $input) {
70 $this->assertEquals($element[3], $validator->isValid($input),
71 'Failed values: ' . $input . ":" . implode("\n", $validator->getMessages()));
76 /**
77 * Ensures that getMessages() returns expected default value
79 * @return void
81 public function testGetMessages()
83 $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
84 $this->assertEquals(array(), $validator->getMessages());
87 /**
88 * Ensures that getMin() returns expected value
90 * @return void
92 public function testGetMin()
94 $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
95 $this->assertEquals(1, $validator->getMin());
98 /**
99 * Ensures that getMax() returns expected value
101 * @return void
103 public function testGetMax()
105 $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
106 $this->assertEquals(10, $validator->getMax());
110 * Ensures that getInclusive() returns expected default value
112 * @return void
114 public function testGetInclusive()
116 $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
117 $this->assertEquals(true, $validator->getInclusive());