TYPO3 CMS  TYPO3_6-2
RequiredValidatorTest.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\\RequiredValidator', array('dummy'), array(), '', FALSE);
34  }
35 
36  public function validDataProvider() {
37  return array(
38  'a' => array('a'),
39  'a b' => array('a b'),
40  '"0"' => array('0'),
41  '0' => array(0)
42  );
43  }
44 
45  public function invalidDataProvider() {
46  return array(
47  'empty string' => array(''),
48  );
49  }
50 
55  public function isValidForValidDataReturnsTrue($input) {
56  $this->subject->setFieldName('myRequired');
57  $requestHandlerMock = $this->helper->getRequestHandler(array(
58  'myRequired' => $input
59  ));
60  $this->subject->injectRequestHandler($requestHandlerMock);
61 
62  $this->assertTrue(
63  $this->subject->isValid()
64  );
65  }
66 
71  public function isValidForInvalidDataReturnsFalse($input) {
72  $this->subject->setFieldName('myRequired');
73  $requestHandlerMock = $this->helper->getRequestHandler(array(
74  'myRequired' => $input
75  ));
76  $this->subject->injectRequestHandler($requestHandlerMock);
77 
78  $this->assertFalse(
79  $this->subject->isValid()
80  );
81  }
82 }