‪TYPO3CMS  11.5
CountValidatorTest.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 ‪CountValidatorTest extends UnitTestCase
27 {
32  {
33  $options = ['minimum' => 1, 'maximum' => 2];
34  ‪$validator = $this->getMockBuilder(CountValidator::class)
35  ->onlyMethods(['translateErrorMessage'])
36  ->setConstructorArgs([$options])
37  ->getMock();
38 
39  $input = [
40  'klaus',
41  'steve',
42  ];
43 
44  self::assertFalse(‪$validator->validate($input)->hasErrors());
45  }
46 
51  {
52  $options = ['minimum' => 2, 'maximum' => 3];
53  ‪$validator = $this->getMockBuilder(CountValidator::class)
54  ->onlyMethods(['translateErrorMessage'])
55  ->setConstructorArgs([$options])
56  ->getMock();
57 
58  $input = [
59  'klaus',
60  'steve',
61  ];
62 
63  self::assertFalse(‪$validator->validate($input)->hasErrors());
64  }
65 
70  {
71  $options = ['minimum' => 2, 'maximum' => 2];
72  ‪$validator = $this->getMockBuilder(CountValidator::class)
73  ->onlyMethods(['translateErrorMessage'])
74  ->setConstructorArgs([$options])
75  ->getMock();
76 
77  $input = [
78  'klaus',
79  'steve',
80  ];
81 
82  self::assertFalse(‪$validator->validate($input)->hasErrors());
83  }
84 
89  {
90  $options = ['minimum' => 1, 'maximum' => 2];
91  ‪$validator = $this->getMockBuilder(CountValidator::class)
92  ->onlyMethods(['translateErrorMessage'])
93  ->setConstructorArgs([$options])
94  ->getMock();
95 
96  $input = [
97  'klaus',
98  'steve',
99  'francine',
100  ];
101 
102  self::assertTrue(‪$validator->validate($input)->hasErrors());
103  }
104 
109  {
110  $options = ['minimum' => 2, 'maximum' => 3];
111  ‪$validator = $this->getMockBuilder(CountValidator::class)
112  ->onlyMethods(['translateErrorMessage'])
113  ->setConstructorArgs([$options])
114  ->getMock();
115 
116  $input = [
117  'klaus',
118  ];
119 
120  self::assertTrue(‪$validator->validate($input)->hasErrors());
121  }
122 }
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest
Definition: CountValidatorTest.php:27
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsTrueIfInputCountHasMoreItemsAsMaximumValue
‪CountValidatorReturnsTrueIfInputCountHasMoreItemsAsMaximumValue()
Definition: CountValidatorTest.php:88
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation
Definition: CountValidatorTest.php:18
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsTrueIfInputCountHasLessItemsAsMinimumValue
‪CountValidatorReturnsTrueIfInputCountHasLessItemsAsMinimumValue()
Definition: CountValidatorTest.php:108
‪TYPO3\CMS\Form\Mvc\Validation\CountValidator
Definition: CountValidator.php:33
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimumAndMaximum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimumAndMaximum()
Definition: CountValidatorTest.php:69
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimum()
Definition: CountValidatorTest.php:50
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMaximum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMaximum()
Definition: CountValidatorTest.php:31