Skip to content

Commit 3c5adf2

Browse files
committed
test: add test cases for current behavior
1 parent c1b39dc commit 3c5adf2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tests/system/Validation/RulesTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function testRequired(array $data, bool $expected): void
6363
public static function provideRequired(): iterable
6464
{
6565
yield from [
66+
[[], false],
6667
[['foo' => null], false],
6768
[['foo' => 123], true],
6869
[['foo' => null, 'bar' => 123], false],
@@ -138,6 +139,11 @@ public static function providePermitEmpty(): iterable
138139
{
139140
yield from [
140141
// If the rule is only `permit_empty`, any value will pass.
142+
[
143+
['foo' => 'permit_empty|valid_email'],
144+
[],
145+
true,
146+
],
141147
[
142148
['foo' => 'permit_empty|valid_email'],
143149
['foo' => ''],
@@ -203,8 +209,8 @@ public static function providePermitEmpty(): iterable
203209
['foo' => 'invalid'],
204210
false,
205211
],
206-
// Required has more priority
207212
[
213+
// Required has more priority
208214
['foo' => 'permit_empty|required|valid_email'],
209215
['foo' => ''],
210216
false,
@@ -224,8 +230,8 @@ public static function providePermitEmpty(): iterable
224230
['foo' => false],
225231
false,
226232
],
227-
// This tests will return true because the input data is trimmed
228233
[
234+
// This tests will return true because the input data is trimmed
229235
['foo' => 'permit_empty|required'],
230236
['foo' => '0'],
231237
true,
@@ -280,8 +286,8 @@ public static function providePermitEmpty(): iterable
280286
['foo' => '', 'bar' => 1],
281287
true,
282288
],
283-
// Testing with closure
284289
[
290+
// Testing with closure
285291
['foo' => ['permit_empty', static fn ($value) => true]],
286292
['foo' => ''],
287293
true,

tests/system/Validation/StrictRules/RulesTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function testPermitEmptyStrict(array $rules, array $data, bool $expected)
5353
public static function providePermitEmptyStrict(): iterable
5454
{
5555
yield from [
56+
[
57+
['foo' => 'permit_empty'],
58+
[],
59+
true,
60+
],
5661
[
5762
['foo' => 'permit_empty'],
5863
['foo' => ''],

0 commit comments

Comments
 (0)