‪TYPO3CMS  ‪main
AlphanumericValidatorTest.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 
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪AlphanumericValidatorTest extends FunctionalTestCase
27 {
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('default');
32  $request = (new ‪ServerRequest())->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE);
33  ‪$GLOBALS['TYPO3_REQUEST'] = $request;
34  }
35 
40  {
41  $subject = new ‪AlphanumericValidator();
42  $subject->setOptions([]);
43  self::assertFalse($subject->validate('12ssDF34daweidf')->hasErrors());
44  }
45 
50  {
51  $subject = new ‪AlphanumericValidator();
52  $subject->setOptions([]);
53  self::assertTrue($subject->validate('adsf%&/$jklsfdö')->hasErrors());
54  }
55 
60  {
61  $subject = new ‪AlphanumericValidator();
62  $subject->setOptions([]);
63  self::assertCount(1, $subject->validate('adsf%&/$jklsfdö')->getErrors());
64  }
65 
70  {
71  $subject = new ‪AlphanumericValidator();
72  $subject->setOptions([]);
73  self::assertFalse($subject->validate('12ssDF34daweidfäøüößØœ你好')->hasErrors());
74  }
75 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator
Definition: AlphanumericValidatorTest.php:18
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\AlphanumericValidatorTest
Definition: AlphanumericValidatorTest.php:27
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\AlphanumericValidatorTest\alphanumericValidatorShouldReturnNoErrorsForAnAlphanumericUnicodeString
‪alphanumericValidatorShouldReturnNoErrorsForAnAlphanumericUnicodeString()
Definition: AlphanumericValidatorTest.php:69
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\AlphanumericValidatorTest\alphanumericValidatorShouldReturnNoErrorsForAnAlphanumericString
‪alphanumericValidatorShouldReturnNoErrorsForAnAlphanumericString()
Definition: AlphanumericValidatorTest.php:39
‪TYPO3\CMS\Extbase\Validation\Validator\AlphanumericValidator
Definition: AlphanumericValidator.php:24
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\AlphanumericValidatorTest\alphanumericValidatorReturnsErrorsForAStringWithSpecialCharacters
‪alphanumericValidatorReturnsErrorsForAStringWithSpecialCharacters()
Definition: AlphanumericValidatorTest.php:49
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\AlphanumericValidatorTest\setUp
‪setUp()
Definition: AlphanumericValidatorTest.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Extbase\Tests\Functional\Validation\Validator\AlphanumericValidatorTest\alphanumericValidatorCreatesTheCorrectErrorForAnInvalidSubject
‪alphanumericValidatorCreatesTheCorrectErrorForAnInvalidSubject()
Definition: AlphanumericValidatorTest.php:59