Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 3cda0ad

Browse files
committed
Updates providerBasic to do one value per set
Splits each "values" argument into discrete sets. Names each set based on behavior being tested.
1 parent 8f08111 commit 3cda0ad

File tree

1 file changed

+123
-22
lines changed

1 file changed

+123
-22
lines changed

test/BetweenTest.php

Lines changed: 123 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,74 +21,175 @@ class BetweenTest extends TestCase
2121
public function providerBasic()
2222
{
2323
return [
24-
[
24+
'inclusive-int-valid-floor' => [
2525
'min' => 1,
2626
'max' => 100,
2727
'inclusive' => true,
2828
'expected' => true,
29-
'values' => [1, 10, 100],
29+
'value' => 1,
3030
],
31-
[
31+
'inclusive-int-valid-between' => [
32+
'min' => 1,
33+
'max' => 100,
34+
'inclusive' => true,
35+
'expected' => true,
36+
'value' => 10,
37+
],
38+
'inclusive-int-valid-ceiling' => [
39+
'min' => 1,
40+
'max' => 100,
41+
'inclusive' => true,
42+
'expected' => true,
43+
'value' => 100,
44+
],
45+
'inclusive-int-invaild-below' => [
3246
'min' => 1,
3347
'max' => 100,
3448
'inclusive' => true,
3549
'expected' => false,
36-
'values' => [0, 0.99, 100.01, 101],
50+
'value' => 0,
3751
],
38-
[
52+
'inclusive-int-invalid-below-fractional' => [
53+
'min' => 1,
54+
'max' => 100,
55+
'inclusive' => true,
56+
'expected' => false,
57+
'value' => 0.99,
58+
],
59+
'inclusive-int-invalid-above-fractional' => [
60+
'min' => 1,
61+
'max' => 100,
62+
'inclusive' => true,
63+
'expected' => false,
64+
'value' => 100.01,
65+
],
66+
'inclusive-int-invalid-above' => [
67+
'min' => 1,
68+
'max' => 100,
69+
'inclusive' => true,
70+
'expected' => false,
71+
'value' => 101,
72+
],
73+
'exclusive-int-invalid-below' => [
3974
'min' => 1,
4075
'max' => 100,
4176
'inclusive' => false,
4277
'expected' => false,
43-
'values' => [0, 1, 100, 101],
78+
'value' => 0,
4479
],
45-
[
80+
'exclusive-int-invalid-floor' => [
81+
'min' => 1,
82+
'max' => 100,
83+
'inclusive' => false,
84+
'expected' => false,
85+
'value' => 1,
86+
],
87+
'exclusive-int-invalid-ceiling' => [
88+
'min' => 1,
89+
'max' => 100,
90+
'inclusive' => false,
91+
'expected' => false,
92+
'value' => 100,
93+
],
94+
'exclusive-int-invalid-above' => [
95+
'min' => 1,
96+
'max' => 100,
97+
'inclusive' => false,
98+
'expected' => false,
99+
'value' => 101,
100+
],
101+
'inclusive-string-valid-floor' => [
46102
'min' => 'a',
47103
'max' => 'z',
48104
'inclusive' => true,
49105
'expected' => true,
50-
'values' => ['a', 'b', 'y', 'z'],
106+
'value' => 'a',
51107
],
52-
[
108+
'inclusive-string-valid-between' => [
109+
'min' => 'a',
110+
'max' => 'z',
111+
'inclusive' => true,
112+
'expected' => true,
113+
'value' => 'm',
114+
],
115+
'inclusive-string-valid-ceiling' => [
116+
'min' => 'a',
117+
'max' => 'z',
118+
'inclusive' => true,
119+
'expected' => true,
120+
'value' => 'z',
121+
],
122+
'exclusive-string-invalid-out-of-range' => [
53123
'min' => 'a',
54124
'max' => 'z',
55125
'inclusive' => false,
56126
'expected' => false,
57-
'values' => ['!', 'a', 'z'],
127+
'value' => '!',
58128
],
59-
[
129+
'exclusive-string-invalid-floor' => [
130+
'min' => 'a',
131+
'max' => 'z',
132+
'inclusive' => false,
133+
'expected' => false,
134+
'value' => 'a',
135+
],
136+
'exclusive-string-invalid-ceiling' => [
137+
'min' => 'a',
138+
'max' => 'z',
139+
'inclusive' => false,
140+
'expected' => false,
141+
'value' => 'z',
142+
],
143+
'inclusive-int-invalid-string' => [
60144
'min' => 0,
61145
'max' => 99999999,
62146
'inclusive' => true,
63147
'expected' => false,
64-
'values' => ['asdasd', 'q'],
148+
'value' => 'asdasd',
65149
],
66-
[
150+
'inclusive-int-invalid-char' => [
151+
'min' => 0,
152+
'max' => 99999999,
153+
'inclusive' => true,
154+
'expected' => false,
155+
'value' => 'q',
156+
],
157+
'inclusive-string-invalid-zero' => [
158+
'min' => 'a',
159+
'max' => 'zzzzz',
160+
'inclusive' => true,
161+
'expected' => false,
162+
'value' => 0,
163+
],
164+
'inclusive-string-invalid-non-zero' => [
67165
'min' => 'a',
68166
'max' => 'zzzzz',
69167
'inclusive' => true,
70168
'expected' => false,
71-
'values' => [0, 10, 548],
169+
'value' => 10,
72170
],
73171
];
74172
}
75173
/**
76174
* Ensures that the validator follows expected behavior
77175
*
78176
* @dataProvider providerBasic
177+
* @param int|float|string $min
178+
* @param int|float|string $max
179+
* @param bool $inclusive
180+
* @param bool $expected
181+
* @param mixed $value
79182
* @return void
80183
*/
81-
public function testBasic($min, $max, $inclusive, $expected, $values)
184+
public function testBasic($min, $max, $inclusive, $expected, $value)
82185
{
83186
$validator = new Between(['min' => $min, 'max' => $max, 'inclusive' => $inclusive]);
84187

85-
foreach ($values as $input) {
86-
$this->assertEquals(
87-
$expected,
88-
$validator->isValid($input),
89-
'Failed values: ' . $input . ":" . implode("\n", $validator->getMessages())
90-
);
91-
}
188+
$this->assertSame(
189+
$expected,
190+
$validator->isValid($value),
191+
'Failed value: ' . $value . ':' . implode("\n", $validator->getMessages())
192+
);
92193
}
93194

94195
/**

0 commit comments

Comments
 (0)