TYPO3 CMS  TYPO3_6-2
GreaterThanValidatorTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $helper;
26 
30  protected $subject;
31 
32  public function setUp() {
33  $this->helper = new \TYPO3\CMS\Form\Tests\Unit\Validation\Helper();
34  $this->subject = $this->getMock('TYPO3\\CMS\\Form\\Validation\\GreaterThanValidator', array('dummy'), array(), '', FALSE);
35  }
36 
37  public function validNumberProvider() {
38  return array(
39  '13 > 12' => array(array(12, 13)),
40  );
41  }
42 
43  public function invalidNumberProvider() {
44  return array(
45  '12.1 > 12' => array(array(12, 12.1)),
46  '12 > 12' => array(array(12, 12)),
47  '11.99 > 12' => array(array(12, 11.99))
48  );
49  }
50 
55  public function isValidForValidInputReturnsTrue($input) {
56  $this->subject->setFieldName('myFile');
57  $this->subject->setMinimum($input[0]);
58  $requestHandlerMock = $this->helper->getRequestHandler(array(
59  'myFile' => $input[1]
60  ));
61  $this->subject->injectRequestHandler($requestHandlerMock);
62 
63  $this->assertTrue(
64  $this->subject->isValid()
65  );
66  }
67 
72  public function isValidForInvalidInputReturnsFalse($input) {
73  $this->subject->setFieldName('myFile');
74  $this->subject->setMinimum($input[0]);
75  $requestHandlerMock = $this->helper->getRequestHandler(array(
76  'myFile' => $input[1]
77  ));
78  $this->subject->injectRequestHandler($requestHandlerMock);
79 
80  $this->assertFalse(
81  $this->subject->isValid()
82  );
83  }
84 }