‪TYPO3CMS  9.5
TextValidatorTest.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 
21 {
25  protected ‪$validatorClassName = \TYPO3\CMS\Extbase\Validation\Validator\TextValidator::class;
26 
27  public function ‪setup()
28  {
29  $this->validator = $this->getMockBuilder($this->validatorClassName)
30  ->setMethods(['translateErrorMessage'])
31  ->getMock();
32  }
33 
38  {
39  $this->assertFalse($this->validator->validate('this is a very simple string')->hasErrors());
40  }
41 
46  {
47  $sampleText = 'Ierd Frot uechter mä get, Kirmesdag Milliounen all en, sinn main Stréi mä och. nVu dan durch jéngt gréng, ze rou Monn voll stolz. nKe kille Minutt d\'Kirmes net. Hir Wand Lann Gaas da, wär hu Heck Gart zënter, Welt Ronn grousse der ke. Wou fond eraus Wisen am. Hu dénen d\'Gaassen eng, eng am virun geplot d\'Lëtzebuerger, get botze rëscht Blieder si. Dat Dauschen schéinste Milliounen fu. Ze riede méngem Keppchen déi, si gét fergiess erwaacht, räich jéngt duerch en nun. Gëtt Gaas d\'Vullen hie hu, laacht Grénge der dé. Gemaacht gehéiert da aus, gutt gudden d\'wäiss mat wa.';
48  $this->assertFalse($this->validator->validate($sampleText)->hasErrors());
49  }
50 
55  {
56  $sampleText = '3% of most people tend to use semikolae; we need to check & allow that. And hashes (#) are not evil either, nor is the sign called \'quote\'.';
57  $this->assertFalse($this->validator->validate($sampleText)->hasErrors());
58  }
59 
64  {
65  $this->assertTrue($this->validator->validate('<span style="color: #BBBBBB;">a nice text</span>')->hasErrors());
66  }
67 
72  {
73  // we only test for the error code, after the translation Method for message is mocked anyway
74  $expected = [new \TYPO3\CMS\Extbase\Validation\Error(null, 1221565786)];
75  $this->assertEquals($expected, $this->validator->validate('<span style="color: #BBBBBB;">a nice text</span>')->getErrors());
76  }
77 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\textValidatorReturnsNoErrorForASimpleString
‪textValidatorReturnsNoErrorForASimpleString()
Definition: TextValidatorTest.php:36
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\setup
‪setup()
Definition: TextValidatorTest.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\textValidatorAllowsTheNewLineCharacter
‪textValidatorAllowsTheNewLineCharacter()
Definition: TextValidatorTest.php:44
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\textValidatorReturnsErrorForAStringWithHtml
‪textValidatorReturnsErrorForAStringWithHtml()
Definition: TextValidatorTest.php:62
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest
Definition: TextValidatorTest.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\textValidatorAllowsCommonSpecialCharacters
‪textValidatorAllowsCommonSpecialCharacters()
Definition: TextValidatorTest.php:53
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: TextValidatorTest.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:2
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTestcase
Definition: AbstractValidatorTestcase.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\TextValidatorTest\textValidatorCreatesTheCorrectErrorIfTheSubjectContainsHtmlEntities
‪textValidatorCreatesTheCorrectErrorIfTheSubjectContainsHtmlEntities()
Definition: TextValidatorTest.php:70