‪TYPO3CMS  11.5
NotEmptyValidatorTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪NotEmptyValidatorTest extends UnitTestCase
27 {
32  {
33  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
34  self::assertFalse(‪$validator->validate('a not empty string')->hasErrors());
35  }
36 
41  {
42  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
43  self::assertTrue(‪$validator->validate('')->hasErrors());
44  }
45 
50  {
51  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
52  self::assertTrue(‪$validator->validate(null)->hasErrors());
53  }
54 
59  {
60  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
61  self::assertCount(1, ‪$validator->validate('')->getErrors());
62  }
63 
68  {
69  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
70  self::assertCount(1, ‪$validator->validate(null)->getErrors());
71  }
72 
77  {
78  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
79  self::assertTrue(‪$validator->validate([])->hasErrors());
80  self::assertFalse(‪$validator->validate([1 => 2])->hasErrors());
81  }
82 
87  {
88  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
89  self::assertTrue(‪$validator->validate(new \SplObjectStorage())->hasErrors());
90  }
91 
96  {
97  $countableObject = new \SplObjectStorage();
98  $countableObject->attach(new \stdClass());
99  ‪$validator = $this->getMockBuilder(NotEmptyValidator::class)->onlyMethods(['translateErrorMessage'])->getMock();
100  self::assertFalse(‪$validator->validate($countableObject)->hasErrors());
101  }
102 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsErrorForANullValue
‪notEmptyValidatorReturnsErrorForANullValue()
Definition: NotEmptyValidatorTest.php:49
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForNotEmptyCountableObjects
‪notEmptyValidatorWorksForNotEmptyCountableObjects()
Definition: NotEmptyValidatorTest.php:95
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForEmptyArrays
‪notEmptyValidatorWorksForEmptyArrays()
Definition: NotEmptyValidatorTest.php:76
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsNoErrorForASimpleString
‪notEmptyValidatorReturnsNoErrorForASimpleString()
Definition: NotEmptyValidatorTest.php:31
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForEmptyCountableObjects
‪notEmptyValidatorWorksForEmptyCountableObjects()
Definition: NotEmptyValidatorTest.php:86
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject
‪notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject()
Definition: NotEmptyValidatorTest.php:58
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorCreatesTheCorrectErrorForANullValue
‪notEmptyValidatorCreatesTheCorrectErrorForANullValue()
Definition: NotEmptyValidatorTest.php:67
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:22
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest
Definition: NotEmptyValidatorTest.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsErrorForAnEmptyString
‪notEmptyValidatorReturnsErrorForAnEmptyString()
Definition: NotEmptyValidatorTest.php:40