‪TYPO3CMS  9.5
EmailAddressValidatorTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪EmailAddressValidatorTest extends UnitTestCase
23 {
29  public function ‪validAddresses()
30  {
31  return [
32  ['andreas.foerthner@netlogix.de'],
33  ['user@localhost.localdomain'],
34  ['info@guggenheim.museum'],
35  ['just@test.invalid'],
36  ['just+spam@test.de'],
37  ];
38  }
39 
46  {
48  $subject = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Validation\Validator\EmailAddressValidator::class)
49  ->setMethods(['translateErrorMessage'])
50  ->getMock();
51  $this->assertFalse($subject->validate($address)->hasErrors());
52  }
53 
59  public function ‪invalidAddresses()
60  {
61  return [
62  ['andreas.foerthner@'],
63  ['@typo3.org'],
64  ['someone@typo3.'],
65  ['local@192.168.2'],
66  ['local@192.168.270.1'],
67  ['foo@bar.com' . "\0"],
68  ['foo@bar.org' . chr(10)],
69  ['andreas@foerthner@example.com'],
70  ['some@one.net ']
71  ];
72  }
73 
80  {
82  $subject = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Validation\Validator\EmailAddressValidator::class)
83  ->setMethods(['translateErrorMessage'])
84  ->getMock();
85  $this->assertTrue($subject->validate($address)->hasErrors());
86  }
87 
92  {
94  $subject = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Validation\Validator\EmailAddressValidator::class)
95  ->setMethods(['translateErrorMessage'])
96  ->getMock();
97  $this->assertEquals(1, count($subject->validate('notAValidMail@Address')->getErrors()));
98  }
99 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\EmailAddressValidatorTest\emailAddressValidatorReturnsNoErrorsForAValidEmailAddress
‪emailAddressValidatorReturnsNoErrorsForAValidEmailAddress($address)
Definition: EmailAddressValidatorTest.php:45
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\EmailAddressValidatorTest\validAddresses
‪array validAddresses()
Definition: EmailAddressValidatorTest.php:29
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\EmailAddressValidatorTest
Definition: EmailAddressValidatorTest.php:23
‪TYPO3
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\EmailAddressValidatorTest\invalidAddresses
‪array invalidAddresses()
Definition: EmailAddressValidatorTest.php:59
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\EmailAddressValidatorTest\emailAddressValidatorReturnsFalseForAnInvalidEmailAddress
‪emailAddressValidatorReturnsFalseForAnInvalidEmailAddress($address)
Definition: EmailAddressValidatorTest.php:79
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\EmailAddressValidatorTest\emailValidatorCreatesTheCorrectErrorForAnInvalidEmailAddress
‪emailValidatorCreatesTheCorrectErrorForAnInvalidEmailAddress()
Definition: EmailAddressValidatorTest.php:91
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:2