TYPO3 CMS  TYPO3_6-2
LessThanValidatorTest.php
Go to the documentation of this file.
1 <?php
20 
24  protected $helper;
25 
29  protected $subject;
30 
31  public function setUp() {
32  $this->helper = new \TYPO3\CMS\Form\Tests\Unit\Validation\Helper();
33  $this->subject = $this->getMock('TYPO3\\CMS\\Form\\Validation\\LessthanValidator', array('dummy'), array(), '', FALSE);
34  }
35 
36  public function validValueProvider() {
37  return array(
38  '4 < 8' => array(array(8, 4)),
39  );
40  }
41 
42  public function invalidValueProvider() {
43  return array(
44  '8 < 4' => array(array(4, 8)),
45  '8 < 8' => array(array(8, 8)),
46  );
47  }
48 
53  public function isValidForValidInputReturnsTrue($input) {
54  $this->subject->setFieldName('myLessthan');
55  $this->subject->setMaximum($input[0]);
56  $requestHandlerMock = $this->helper->getRequestHandler(array(
57  'myLessthan' => $input[1]
58  ));
59  $this->subject->injectRequestHandler($requestHandlerMock);
60 
61  $this->assertTrue(
62  $this->subject->isValid()
63  );
64  }
65 
70  public function isValidForInvalidInputReturnsFalse($input) {
71  $this->subject->setFieldName('myLessthan');
72  $this->subject->setMaximum($input[0]);
73  $requestHandlerMock = $this->helper->getRequestHandler(array(
74  'myLessthan' => $input[1]
75  ));
76  $this->subject->injectRequestHandler($requestHandlerMock);
77 
78  $this->assertFalse(
79  $this->subject->isValid()
80  );
81  }
82 }