4 * This script belongs to the Extbase framework. *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
20 * The TYPO3 project - inspiring people to share! *
23 require_once('AbstractValidatorTestcase.php');
26 * Testcase for the email address validator
28 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
30 class Tx_Extbase_Tests_Unit_Validation_Validator_EmailAddressValidatorTest
extends Tx_Extbase_Tests_Unit_Validation_Validator_AbstractValidatorTestcase
{
32 protected $validatorClassName = 'Tx_Extbase_Validation_Validator_EmailAddressValidator';
35 * Data provider with valid email addresses
38 * @author Karsten Dambekalns <karsten@typo3.org>
40 public function validAddresses() {
42 array('andreas.foerthner@netlogix.de'),
43 array('user@localhost'),
44 array('user@localhost.localdomain'),
45 array('info@guggenheim.museum'),
46 array('just@test.invalid'),
47 array('just+spam@test.de'),
48 array('just+spam@192.168.249.100'),
49 array('local@192.168.0.2')
54 * @author Karsten Dambekalns <karsten@typo3.org>
56 * @dataProvider validAddresses
57 * @param mixed $address
59 public function emailAddressValidatorReturnsNoErrorsForAValidEmailAddress($address) {
60 $this->assertFalse($this->validator
->validate($address)->hasErrors());
64 * Data provider with invalid email addresses
67 * @author Karsten Dambekalns <karsten@typo3.org>
69 public function invalidAddresses() {
71 array('andreas.foerthner@'),
73 array('someone@typo3.'),
74 array('local@192.168.2'),
75 array('local@192.168.270.1'),
76 array('foo@bar.com' . chr(0)),
77 array('foo@bar.org' . chr(10)),
78 array('andreas@foerthner@example.com'),
79 array('some@one.net ')
84 * @author Karsten Dambekalns <karsten@typo3.org>
86 * @dataProvider invalidAddresses
87 * @param mixed $address
89 public function emailAddressValidatorReturnsFalseForAnInvalidEmailAddress($address) {
90 $this->assertTrue($this->validator
->validate($address)->hasErrors());
95 * @author Andreas Förthner <andreas.foerthner@netlogix.de>
97 public function emailValidatorCreatesTheCorrectErrorForAnInvalidEmailAddress() {
98 $this->assertEquals(1, count($this->validator
->validate('notAValidMail@Address')->getErrors()));