TYPO3 CMS  TYPO3_6-2
UriValidatorTest.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\\UriValidator', array('dummy'), array(), '', FALSE);
34  }
35 
36  public function validDataProvider() {
37  return array(
38  'http://example.net' => array('http://example.net'),
39  'https://example.net' => array('https://example.net'),
40  'http://a:b@example.net' => array('http://a:b@example.net'),
41  );
42  }
43 
44  public function invalidDataProvider() {
45  return array(
46  'index.php' => array('index.php')
47  );
48  }
49 
54  public function isValidForValidInputReturnsTrue($input) {
55  $this->subject->setFieldName('myUri');
56  $requestHandlerMock = $this->helper->getRequestHandler(array(
57  'myUri' => $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('myUri');
72  $requestHandlerMock = $this->helper->getRequestHandler(array(
73  'myUri' => $input
74  ));
75  $this->subject->injectRequestHandler($requestHandlerMock);
76 
77  $this->assertFalse(
78  $this->subject->isValid()
79  );
80  }
81 }