‪TYPO3CMS  10.4
NotEmptyValidatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪NotEmptyValidatorTest extends UnitTestCase
25 {
29  protected ‪$validatorClassName = NotEmptyValidator::class;
30 
31  public function ‪setup(): void
32  {
33  parent::setUp();
34  $this->validator = $this->getMockBuilder($this->validatorClassName)
35  ->setMethods(['translateErrorMessage'])
36  ->getMock();
37  }
38 
43  {
44  self::assertFalse($this->validator->validate('a not empty string')->hasErrors());
45  }
46 
51  {
52  self::assertTrue($this->validator->validate('')->hasErrors());
53  }
54 
59  {
60  self::assertTrue($this->validator->validate(null)->hasErrors());
61  }
62 
67  {
68  self::assertEquals(1, count($this->validator->validate('')->getErrors()));
69  }
70 
75  {
76  self::assertEquals(1, count($this->validator->validate(null)->getErrors()));
77  }
78 
83  {
84  self::assertTrue($this->validator->validate([])->hasErrors());
85  self::assertFalse($this->validator->validate([1 => 2])->hasErrors());
86  }
87 
92  {
93  self::assertTrue($this->validator->validate(new \SplObjectStorage())->hasErrors());
94  }
95 
100  {
101  $countableObject = new \SplObjectStorage();
102  $countableObject->attach(new \stdClass());
103  self::assertFalse($this->validator->validate($countableObject)->hasErrors());
104  }
105 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsErrorForANullValue
‪notEmptyValidatorReturnsErrorForANullValue()
Definition: NotEmptyValidatorTest.php:57
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForNotEmptyCountableObjects
‪notEmptyValidatorWorksForNotEmptyCountableObjects()
Definition: NotEmptyValidatorTest.php:98
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForEmptyArrays
‪notEmptyValidatorWorksForEmptyArrays()
Definition: NotEmptyValidatorTest.php:81
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsNoErrorForASimpleString
‪notEmptyValidatorReturnsNoErrorForASimpleString()
Definition: NotEmptyValidatorTest.php:41
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForEmptyCountableObjects
‪notEmptyValidatorWorksForEmptyCountableObjects()
Definition: NotEmptyValidatorTest.php:90
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject
‪notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject()
Definition: NotEmptyValidatorTest.php:65
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\setup
‪setup()
Definition: NotEmptyValidatorTest.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: NotEmptyValidatorTest.php:28
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorCreatesTheCorrectErrorForANullValue
‪notEmptyValidatorCreatesTheCorrectErrorForANullValue()
Definition: NotEmptyValidatorTest.php:73
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:22
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:16
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest
Definition: NotEmptyValidatorTest.php:25
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsErrorForAnEmptyString
‪notEmptyValidatorReturnsErrorForAnEmptyString()
Definition: NotEmptyValidatorTest.php:49