Skip to content

Commit

Permalink
Merge pull request #6175 from kenjis/fix-tests-Validation-permit_empty
Browse files Browse the repository at this point in the history
test: fix tests for permit_empty
  • Loading branch information
kenjis authored Jun 24, 2022
2 parents 1188c64 + 1114668 commit 08bb4b0
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions tests/system/Validation/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,39 +128,60 @@ public function testPermitEmpty(array $rules, array $data, bool $expected): void
public function providePermitEmptyCases(): Generator
{
yield from [
// If the rule is only `permit_empty`, any value will pass.
[
['foo' => 'permit_empty'],
['foo' => 'permit_empty|valid_email'],
['foo' => ''],
true,
],
[
['foo' => 'permit_empty'],
['foo' => 'permit_empty|valid_email'],
['foo' => '0'],
true,
false,
],
[
['foo' => 'permit_empty'],
['foo' => 'permit_empty|valid_email'],
['foo' => '-0'],
false,
],
[
['foo' => 'permit_empty|valid_emails'],
['foo' => 0],
true,
false,
],
[
['foo' => 'permit_empty|valid_email'],
['foo' => -0],
false,
],
[
['foo' => 'permit_empty'],
['foo' => 'permit_empty|valid_email'],
['foo' => 0.0],
true,
false,
],
[
['foo' => 'permit_empty'],
['foo' => null],
true,
['foo' => 'permit_empty|valid_emails'],
['foo' => '0.0'],
false,
],
[
['foo' => 'permit_empty'],
['foo' => false],
['foo' => 'permit_empty|valid_email'],
['foo' => -0.0],
false,
],
[
['foo' => 'permit_empty|valid_email'],
['foo' => '-0.0'],
false,
],
[
['foo' => 'permit_empty|valid_email'],
['foo' => null],
true,
],
[
['foo' => 'permit_empty|valid_email'],
['foo' => ''],
['foo' => false],
true,
],
[
Expand Down

0 comments on commit 08bb4b0

Please sign in to comment.