‪TYPO3CMS  10.4
BooleanValidatorTest.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 ‪BooleanValidatorTest extends UnitTestCase
27 {
32  {
33  $options = ['is' => 'false'];
34  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
35  ->setMethods(['translateErrorMessage'])
36  ->setConstructorArgs([$options])
37  ->getMock();
38  self::assertFalse(‪$validator->validate(false)->hasErrors());
39  }
40 
45  {
46  $options = ['is' => 'true'];
47  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
48  ->setMethods(['translateErrorMessage'])
49  ->setConstructorArgs([$options])
50  ->getMock();
51  self::assertFalse(‪$validator->validate(true)->hasErrors());
52  }
53 
58  {
59  $options = ['is' => true];
60  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
61  ->setMethods(['translateErrorMessage'])
62  ->setConstructorArgs([$options])
63  ->getMock();
64  self::assertFalse(‪$validator->validate(true)->hasErrors());
65  }
66 
71  {
72  $options = ['is' => false];
73  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
74  ->setMethods(['translateErrorMessage'])
75  ->setConstructorArgs([$options])
76  ->getMock();
77  self::assertFalse(‪$validator->validate(false)->hasErrors());
78  }
79 
84  {
85  $options = ['is' => false];
86  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
87  ->setMethods(['translateErrorMessage'])
88  ->setConstructorArgs([$options])
89  ->getMock();
90  self::assertTrue(‪$validator->validate(true)->hasErrors());
91  }
92 
97  {
98  $options = ['is' => true];
99  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
100  ->setMethods(['translateErrorMessage'])
101  ->setConstructorArgs([$options])
102  ->getMock();
103  self::assertTrue(‪$validator->validate(false)->hasErrors());
104  }
105 
110  {
111  $options = ['is' => true];
112  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
113  ->setMethods(['translateErrorMessage'])
114  ->setConstructorArgs([$options])
115  ->getMock();
116  self::assertTrue(‪$validator->validate('a string')->hasErrors());
117  }
118 
123  {
124  $options = [];
125  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
126  ->setMethods(['translateErrorMessage'])
127  ->setConstructorArgs([$options])
128  ->getMock();
129  self::assertFalse(‪$validator->validate(true)->hasErrors());
130  }
131 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsErrorForTrueWhenFalseExpected
‪booleanValidatorReturnsErrorForTrueWhenFalseExpected()
Definition: BooleanValidatorTest.php:83
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsErrorForFalseWhenTrueExpected
‪booleanValidatorReturnsErrorForFalseWhenTrueExpected()
Definition: BooleanValidatorTest.php:96
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForAFalseStringExpectation
‪booleanValidatorReturnsNoErrorForAFalseStringExpectation()
Definition: BooleanValidatorTest.php:31
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsErrorForAString
‪booleanValidatorReturnsErrorForAString()
Definition: BooleanValidatorTest.php:109
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForATrueStringExpectation
‪booleanValidatorReturnsNoErrorForATrueStringExpectation()
Definition: BooleanValidatorTest.php:44
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForATrueExpectation
‪booleanValidatorReturnsNoErrorForATrueExpectation()
Definition: BooleanValidatorTest.php:57
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsTrueIfNoParameterIsGiven
‪booleanValidatorReturnsTrueIfNoParameterIsGiven()
Definition: BooleanValidatorTest.php:122
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForAFalseExpectation
‪booleanValidatorReturnsNoErrorForAFalseExpectation()
Definition: BooleanValidatorTest.php:70
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest
Definition: BooleanValidatorTest.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:16
‪TYPO3\CMS\Extbase\Validation\Validator\BooleanValidator
Definition: BooleanValidator.php:22