|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de> 00006 * All rights reserved 00007 * 00008 * This class is a backport of the corresponding class of FLOW3. 00009 * All credits go to the v5 team. 00010 * 00011 * This script is part of the TYPO3 project. The TYPO3 project is 00012 * free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * The GNU General Public License can be found at 00018 * http://www.gnu.org/copyleft/gpl.html. 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * Testcase for the email address validator 00030 * 00031 * @package Extbase 00032 * @subpackage extbase 00033 * @version $Id: EmailAddressValidator_testcase.php 2428 2010-07-20 10:18:51Z jocrau $ 00034 */ 00035 class Tx_Extbase_Tests_Unit_Validation_Validator_EmailAddressValidatorTest extends Tx_Extbase_Tests_Unit_BaseTestCase { 00036 00037 /** 00038 * Data provider with valid email addresses 00039 * 00040 * @return array 00041 */ 00042 public function validAddresses() { 00043 return array( 00044 array('andreas.foerthner@netlogix.de'), 00045 array('user@localhost'), 00046 array('user@localhost.localdomain'), 00047 array('info@guggenheim.museum'), 00048 array('just@test.invalid'), 00049 array('just+spam@test.de'), 00050 array('local@192.168.0.2') 00051 ); 00052 } 00053 00054 /** 00055 * @test 00056 * @dataProvider validAddresses 00057 */ 00058 public function emailAddressValidatorReturnsTrueForAValidEmailAddress($address) { 00059 $emailAddressValidator = new Tx_Extbase_Validation_Validator_EmailAddressValidator(); 00060 foreach ($this->validAddresses as $address) { 00061 $this->assertTrue($emailAddressValidator->isValid($address), "$address was declared to be invalid, but it is valid."); 00062 } 00063 } 00064 00065 /** 00066 * Data provider with invalid email addresses 00067 * 00068 * @return array 00069 */ 00070 public function invalidAddresses() { 00071 return array( 00072 array('andreas.foerthner@'), 00073 array('andreas@foerthner@example.com'), 00074 array('@typo3.org'), 00075 array('someone@typo3.'), 00076 array('local@192.168.2'), 00077 array('local@192.168.270.1') 00078 ); 00079 } 00080 00081 /** 00082 * @test 00083 * @dataProvider invalidAddresses 00084 */ 00085 public function emailAddressValidatorReturnsFalseForAnInvalidEmailAddress($address) { 00086 $emailAddressValidator = $this->getMock('Tx_Extbase_Validation_Validator_EmailAddressValidator', array('addError'), array(), '', FALSE); 00087 $this->assertFalse($emailAddressValidator->isValid($address)); 00088 } 00089 00090 /** 00091 * @test 00092 */ 00093 public function emailValidatorCreatesTheCorrectErrorForAnInvalidEmailAddress() { 00094 $emailAddressValidator = $this->getMock('Tx_Extbase_Validation_Validator_EmailAddressValidator', array('addError'), array(), '', FALSE); 00095 $emailAddressValidator->expects($this->once())->method('addError')->with('The given subject was not a valid email address.', 1221559976); 00096 $emailAddressValidator->isValid('notAValidMail@Address'); 00097 } 00098 00099 } 00100 00101 ?>
1.8.0