TYPO3 CMS  TYPO3_6-2
DigitValidatorTest.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\\DigitValidator', array('dummy'), array(), '', FALSE);
34  }
35 
36  public function validDigitProvider() {
37  return array(
38  'stringified integer' => array('2012'),
39  'stringified integer with leading zeros' => array('0002'),
40  );
41  }
42 
43  public function invalidDigitProvider() {
44  return array(
45  'stringified float' => array('0.2012'),
46  'stringified scientific' => array('1.9E+11')
47  );
48  }
49 
54  public function isValidForValidInputReturnsTrue($input) {
55  $this->subject->setFieldName('myDigit');
56  $requestHandlerMock = $this->helper->getRequestHandler(array(
57  'myDigit' => $input
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('myDigit');
72  $requestHandlerMock = $this->helper->getRequestHandler(array(
73  'myDigit' => $input
74  ));
75  $this->subject->injectRequestHandler($requestHandlerMock);
76 
77  $this->assertFalse(
78  $this->subject->isValid()
79  );
80  }
81 }