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