TYPO3 CMS  TYPO3_7-6
BetweenValidatorTest.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 
21 {
25  protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\BetweenValidator::class;
26 
31  {
32  return [
33  '3 < 5 < 7' => [[3, 5, 7]],
34  '0 < 10 < 20' => [[0, 10, 20]],
35  '-10 < 0 < 10' => [[-10, 0, 10]],
36  '-20 < -10 < 0' => [[-20, -10, 0]],
37  '1 < 2 < 3' => [[1, 2, 3]],
38  '1 < 1.01 < 1.1' => [[1, 1.01, 1.1]],
39  ];
40  }
41 
46  {
47  return [
48  '1 < 1 < 2' => [[1, 1, 2]],
49  '1 < 2 < 2' => [[1, 2, 2]],
50  '1.1 < 1.1 < 1.2' => [[1.1, 1.1, 1.2]],
51  '1.1 < 1.2 < 1.2' => [[1.1, 1.2, 1.2]],
52  '-10.1234 < -10.12340 < 10' => [[-10.1234, -10.12340, 10]],
53  '100 < 0 < -100' => [[100, 0, -100]]
54  ];
55  }
56 
60  public function validInclusiveDataProvider()
61  {
62  return [
63  '1 ≤ 1 ≤ 1' => [[1, 1, 1]],
64  '-10.1234 ≤ -10.12340 ≤ 10' => [[-10.1234, -10.12340, 10]],
65  '-10.1234 ≤ -10 ≤ 10' => [[-10.1234, -10.12340, 10]],
66  ];
67  }
68 
69  public function invalidInclusiveDataProvider()
70  {
71  return [
72  '-10.1234 ≤ -10.12345 ≤ 10' => [[-10.1234, -10.12345, 10]],
73  '100 ≤ 0 ≤ -100' => [[100, 0, -100]]
74  ];
75  }
76 
83  {
84  $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
85  $options['minimum'] = $input[0];
86  $options['maximum'] = $input[2];
87  $subject = $this->createSubject($options);
88 
89  $this->assertEmpty(
90  $subject->validate($input[1])->getErrors()
91  );
92  }
93 
100  {
101  $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
102  $options['minimum'] = $input[0];
103  $options['maximum'] = $input[2];
104  $options['inclusive'] = true;
105  $subject = $this->createSubject($options);
106 
107  $this->assertEmpty(
108  $subject->validate($input[1])->getErrors()
109  );
110  }
111 
118  {
119  $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
120  $options['minimum'] = $input[0];
121  $options['maximum'] = $input[2];
122  $subject = $this->createSubject($options);
123 
124  $this->assertNotEmpty(
125  $subject->validate($input[1])->getErrors()
126  );
127  }
128 
135  {
136  $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
137  $options['minimum'] = $input[0];
138  $options['maximum'] = $input[2];
139  $options['inclusive'] = true;
140  $subject = $this->createSubject($options);
141 
142  $this->assertNotEmpty(
143  $subject->validate($input[1])->getErrors()
144  );
145  }
146 }