‪TYPO3CMS  9.5
BooleanValidatorTest.php
Go to the documentation of this file.
1 <?php
2 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 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪BooleanValidatorTest extends UnitTestCase
25 {
30  {
31  $options = ['is' => 'false'];
32  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
33  ->setMethods(['translateErrorMessage'])
34  ->setConstructorArgs([$options])
35  ->getMock();
36  $this->assertFalse(‪$validator->validate(false)->hasErrors());
37  }
38 
43  {
44  $options = ['is' => 'true'];
45  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
46  ->setMethods(['translateErrorMessage'])
47  ->setConstructorArgs([$options])
48  ->getMock();
49  $this->assertFalse(‪$validator->validate(true)->hasErrors());
50  }
51 
56  {
57  $options = ['is' => true];
58  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
59  ->setMethods(['translateErrorMessage'])
60  ->setConstructorArgs([$options])
61  ->getMock();
62  $this->assertFalse(‪$validator->validate(true)->hasErrors());
63  }
64 
69  {
70  $options = ['is' => false];
71  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
72  ->setMethods(['translateErrorMessage'])
73  ->setConstructorArgs([$options])
74  ->getMock();
75  $this->assertFalse(‪$validator->validate(false)->hasErrors());
76  }
77 
82  {
83  $options = ['is' => false];
84  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
85  ->setMethods(['translateErrorMessage'])
86  ->setConstructorArgs([$options])
87  ->getMock();
88  $this->assertTrue(‪$validator->validate(true)->hasErrors());
89  }
90 
95  {
96  $options = ['is' => true];
97  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
98  ->setMethods(['translateErrorMessage'])
99  ->setConstructorArgs([$options])
100  ->getMock();
101  $this->assertTrue(‪$validator->validate(false)->hasErrors());
102  }
103 
108  {
109  $options = ['is' => true];
110  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
111  ->setMethods(['translateErrorMessage'])
112  ->setConstructorArgs([$options])
113  ->getMock();
114  $this->assertTrue(‪$validator->validate('a string')->hasErrors());
115  }
116 
121  {
122  $options = [];
123  ‪$validator = $this->getMockBuilder(BooleanValidator::class)
124  ->setMethods(['translateErrorMessage'])
125  ->setConstructorArgs([$options])
126  ->getMock();
127  $this->assertFalse(‪$validator->validate(true)->hasErrors());
128  }
129 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsErrorForTrueWhenFalseExpected
‪booleanValidatorReturnsErrorForTrueWhenFalseExpected()
Definition: BooleanValidatorTest.php:81
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsErrorForFalseWhenTrueExpected
‪booleanValidatorReturnsErrorForFalseWhenTrueExpected()
Definition: BooleanValidatorTest.php:94
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForAFalseStringExpectation
‪booleanValidatorReturnsNoErrorForAFalseStringExpectation()
Definition: BooleanValidatorTest.php:29
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsErrorForAString
‪booleanValidatorReturnsErrorForAString()
Definition: BooleanValidatorTest.php:107
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForATrueStringExpectation
‪booleanValidatorReturnsNoErrorForATrueStringExpectation()
Definition: BooleanValidatorTest.php:42
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForATrueExpectation
‪booleanValidatorReturnsNoErrorForATrueExpectation()
Definition: BooleanValidatorTest.php:55
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsTrueIfNoParameterIsGiven
‪booleanValidatorReturnsTrueIfNoParameterIsGiven()
Definition: BooleanValidatorTest.php:120
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest\booleanValidatorReturnsNoErrorForAFalseExpectation
‪booleanValidatorReturnsNoErrorForAFalseExpectation()
Definition: BooleanValidatorTest.php:68
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\BooleanValidatorTest
Definition: BooleanValidatorTest.php:25
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:2
‪TYPO3\CMS\Extbase\Validation\Validator\BooleanValidator
Definition: BooleanValidator.php:21