‪TYPO3CMS  9.5
NotEmptyValidatorTest.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\NotEmptyValidator::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('a not empty string')->hasErrors());
40  }
41 
46  {
47  $this->assertTrue($this->validator->validate('')->hasErrors());
48  }
49 
54  {
55  $this->assertTrue($this->validator->validate(null)->hasErrors());
56  }
57 
62  {
63  $this->assertEquals(1, count($this->validator->validate('')->getErrors()));
64  }
65 
70  {
71  $this->assertEquals(1, count($this->validator->validate(null)->getErrors()));
72  }
73 
78  {
79  $this->assertTrue($this->validator->validate([])->hasErrors());
80  $this->assertFalse($this->validator->validate([1 => 2])->hasErrors());
81  }
82 
87  {
88  $this->assertTrue($this->validator->validate(new \SplObjectStorage())->hasErrors());
89  }
90 
95  {
96  $countableObject = new \SplObjectStorage();
97  $countableObject->attach(new \stdClass());
98  $this->assertFalse($this->validator->validate($countableObject)->hasErrors());
99  }
100 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsErrorForANullValue
‪notEmptyValidatorReturnsErrorForANullValue()
Definition: NotEmptyValidatorTest.php:52
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForNotEmptyCountableObjects
‪notEmptyValidatorWorksForNotEmptyCountableObjects()
Definition: NotEmptyValidatorTest.php:93
‪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:36
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorWorksForEmptyCountableObjects
‪notEmptyValidatorWorksForEmptyCountableObjects()
Definition: NotEmptyValidatorTest.php:85
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject
‪notEmptyValidatorCreatesTheCorrectErrorForAnEmptySubject()
Definition: NotEmptyValidatorTest.php:60
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\setup
‪setup()
Definition: NotEmptyValidatorTest.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\$validatorClassName
‪string $validatorClassName
Definition: NotEmptyValidatorTest.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorCreatesTheCorrectErrorForANullValue
‪notEmptyValidatorCreatesTheCorrectErrorForANullValue()
Definition: NotEmptyValidatorTest.php:68
‪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\NotEmptyValidatorTest
Definition: NotEmptyValidatorTest.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\NotEmptyValidatorTest\notEmptyValidatorReturnsErrorForAnEmptyString
‪notEmptyValidatorReturnsErrorForAnEmptyString()
Definition: NotEmptyValidatorTest.php:44