TYPO3 CMS  TYPO3_6-2
EmailValidatorTest.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\\EmailValidator', array('dummy'), array(), '', FALSE);
34  }
35 
36  public function validEmailProvider() {
37  return array(
38  'a@b.de' => array('a@b.de'),
39  'somebody@mymac.local' => array('somebody@mymac.local')
40  );
41  }
42 
43  public function invalidEmailProvider() {
44  return array(
45  'myemail@' => array('myemail@'),
46  'myemail' => array('myemail'),
47  'somebody@localhost' => array('somebody@localhost'),
48  );
49  }
50 
55  public function isValidForValidInputReturnsTrue($input) {
56  $this->subject->setFieldName('myEmail');
57  $requestHandlerMock = $this->helper->getRequestHandler(array(
58  'myEmail' => $input
59  ));
60  $this->subject->injectRequestHandler($requestHandlerMock);
61 
62  $this->assertTrue(
63  $this->subject->isValid()
64  );
65  }
66 
71  public function isValidForInvalidInputReturnsFalse($input) {
72  $this->subject->setFieldName('myEmail');
73  $requestHandlerMock = $this->helper->getRequestHandler(array(
74  'myEmail' => $input
75  ));
76  $this->subject->injectRequestHandler($requestHandlerMock);
77 
78  $this->assertFalse(
79  $this->subject->isValid()
80  );
81  }
82 }