‪TYPO3CMS  ‪main
EmailAddressValidatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 final class ‪EmailAddressValidatorTest extends FunctionalTestCase
28 {
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('default');
33  $request = (new ‪ServerRequest())->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE);
34  ‪$GLOBALS['TYPO3_REQUEST'] = $request;
35  }
36 
37  #[Test]
39  {
40  $subject = new ‪EmailAddressValidator();
41  $subject->setOptions([]);
42  self::assertFalse($subject->validate('valid.email@example.com')->hasErrors());
43  }
44 
45  #[Test]
47  {
48  $subject = new ‪EmailAddressValidator();
49  $subject->setOptions([]);
50  self::assertTrue($subject->validate('@typo3.org')->hasErrors());
51  }
52 
53  #[Test]
55  {
56  $subject = new ‪EmailAddressValidator();
57  $subject->setOptions([]);
58  self::assertTrue($subject->validate(123)->hasErrors());
59  }
60 
61  #[Test]
63  {
64  $subject = new ‪EmailAddressValidator();
65  $subject->setOptions([]);
66  self::assertCount(1, $subject->validate('someone@typo3.')->getErrors());
67  }
68 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator
Definition: AlphanumericValidatorTest.php:18
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\EmailAddressValidatorTest\setUp
‪setUp()
Definition: EmailAddressValidatorTest.php:29
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\EmailAddressValidatorTest\emailValidatorCreatesTheCorrectErrorForAnInvalidEmailAddress
‪emailValidatorCreatesTheCorrectErrorForAnInvalidEmailAddress()
Definition: EmailAddressValidatorTest.php:62
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\EmailAddressValidatorTest
Definition: EmailAddressValidatorTest.php:28
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\EmailAddressValidatorTest\emailAddressValidatorReturnsFalseForNonStringAddress
‪emailAddressValidatorReturnsFalseForNonStringAddress()
Definition: EmailAddressValidatorTest.php:54
‪TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator
Definition: EmailAddressValidator.php:26
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\EmailAddressValidatorTest\emailAddressValidatorReturnsNoErrorsForAValidEmailAddress
‪emailAddressValidatorReturnsNoErrorsForAValidEmailAddress()
Definition: EmailAddressValidatorTest.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\EmailAddressValidatorTest\emailAddressValidatorReturnsFalseForAnInvalidEmailAddress
‪emailAddressValidatorReturnsFalseForAnInvalidEmailAddress()
Definition: EmailAddressValidatorTest.php:46