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