‪TYPO3CMS  10.4
CountValidatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪CountValidatorTest extends UnitTestCase
25 {
26 
31  {
32  $options = ['minimum' => 1, 'maximum' => 2];
33  ‪$validator = $this->getMockBuilder(CountValidator::class)
34  ->setMethods(['translateErrorMessage'])
35  ->setConstructorArgs([$options])
36  ->getMock();
37 
38  $input = [
39  'klaus',
40  'steve'
41  ];
42 
43  self::assertFalse(‪$validator->validate($input)->hasErrors());
44  }
45 
50  {
51  $options = ['minimum' => 2, 'maximum' => 3];
52  ‪$validator = $this->getMockBuilder(CountValidator::class)
53  ->setMethods(['translateErrorMessage'])
54  ->setConstructorArgs([$options])
55  ->getMock();
56 
57  $input = [
58  'klaus',
59  'steve'
60  ];
61 
62  self::assertFalse(‪$validator->validate($input)->hasErrors());
63  }
64 
69  {
70  $options = ['minimum' => 2, 'maximum' => 2];
71  ‪$validator = $this->getMockBuilder(CountValidator::class)
72  ->setMethods(['translateErrorMessage'])
73  ->setConstructorArgs([$options])
74  ->getMock();
75 
76  $input = [
77  'klaus',
78  'steve'
79  ];
80 
81  self::assertFalse(‪$validator->validate($input)->hasErrors());
82  }
83 
88  {
89  $options = ['minimum' => 1, 'maximum' => 2];
90  ‪$validator = $this->getMockBuilder(CountValidator::class)
91  ->setMethods(['translateErrorMessage'])
92  ->setConstructorArgs([$options])
93  ->getMock();
94 
95  $input = [
96  'klaus',
97  'steve',
98  'francine'
99  ];
100 
101  self::assertTrue(‪$validator->validate($input)->hasErrors());
102  }
103 
108  {
109  $options = ['minimum' => 2, 'maximum' => 3];
110  ‪$validator = $this->getMockBuilder(CountValidator::class)
111  ->setMethods(['translateErrorMessage'])
112  ->setConstructorArgs([$options])
113  ->getMock();
114 
115  $input = [
116  'klaus',
117  ];
118 
119  self::assertTrue(‪$validator->validate($input)->hasErrors());
120  }
121 }
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest
Definition: CountValidatorTest.php:25
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsTrueIfInputCountHasMoreItemsAsMaximumValue
‪CountValidatorReturnsTrueIfInputCountHasMoreItemsAsMaximumValue()
Definition: CountValidatorTest.php:87
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation
Definition: CountValidatorTest.php:16
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsTrueIfInputCountHasLessItemsAsMinimumValue
‪CountValidatorReturnsTrueIfInputCountHasLessItemsAsMinimumValue()
Definition: CountValidatorTest.php:107
‪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:68
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimum()
Definition: CountValidatorTest.php:49
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMaximum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMaximum()
Definition: CountValidatorTest.php:30