-
Notifications
You must be signed in to change notification settings - Fork 770
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create regression tests for a few issues
- Loading branch information
1 parent
7cec227
commit ea29c2c
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--FILE-- | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
exceptionAll('https://github.com/Respect/Validation/issues/1334', static function (): void { | ||
v::notEmpty()->iterableType()->each( | ||
v::key('street', v::stringType()->notEmpty()) | ||
->key('region', v::stringType()->notEmpty()) | ||
->key('country', v::stringType()->notEmpty()) | ||
->keyOptional('other', v::nullOr(v::notEmpty()->stringType())) | ||
)->assert( | ||
[ | ||
['region' => 'Oregon', 'country' => 'USA', 'other' => 123], | ||
['street' => '', 'region' => 'Oregon', 'country' => 'USA'], | ||
['street' => 123, 'region' => 'Oregon', 'country' => 'USA'], | ||
] | ||
); | ||
}); | ||
|
||
?> | ||
--EXPECT-- | ||
https://github.com/Respect/Validation/issues/1334 | ||
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ | ||
street must be present | ||
- Each item in `[["region": "Oregon", "country": "USA", "other": 123], ["street": "", "region": "Oregon", "country": "USA"], ["s ... ]` must be valid | ||
- These rules must pass for `["region": "Oregon", "country": "USA", "other": 123]` | ||
- street must be present | ||
- These rules must pass for other | ||
- other must be a string or must be null | ||
- These rules must pass for `["street": "", "region": "Oregon", "country": "USA"]` | ||
- street must not be empty | ||
- These rules must pass for `["street": 123, "region": "Oregon", "country": "USA"]` | ||
- street must be a string | ||
[ | ||
'each' => [ | ||
'__root__' => 'Each item in `[["region": "Oregon", "country": "USA", "other": 123], ["street": "", "region": "Oregon", "country": "USA"], ["s ... ]` must be valid', | ||
'allOf.1' => [ | ||
'__root__' => 'These rules must pass for `["region": "Oregon", "country": "USA", "other": 123]`', | ||
'street' => 'street must be present', | ||
'other' => 'other must be a string or must be null', | ||
], | ||
'allOf.2' => 'street must not be empty', | ||
'allOf.3' => 'street must be a string', | ||
], | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--FILE-- | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
exceptionAll('https://github.com/Respect/Validation/issues/1469', static function (): void { | ||
$data = [ | ||
'order_items' => [ | ||
[ | ||
'product_title' => 'test', | ||
'quantity' => 'test', | ||
], | ||
[ | ||
'product_title2' => 'test', | ||
], | ||
], | ||
]; | ||
|
||
v::arrayVal()->keySet( | ||
v::key('order_items', v::arrayVal()->each(v::keySet( | ||
v::key('product_title', v::stringVal()->notEmpty()), | ||
v::key('quantity', v::intVal()->notEmpty()), | ||
))->notEmpty()), | ||
)->assert($data); | ||
}); | ||
|
||
?> | ||
--EXPECT-- | ||
https://github.com/Respect/Validation/issues/1469 | ||
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ | ||
quantity must be an integer value | ||
- Each item in order_items must be valid | ||
- order_items validation failed | ||
- quantity must be an integer value | ||
- order_items contains both missing and extra keys | ||
- product_title must be present | ||
- quantity must be present | ||
- product_title2 must not be present | ||
[ | ||
'keySet' => [ | ||
'__root__' => 'Each item in order_items must be valid', | ||
'keySet.1' => 'quantity must be an integer value', | ||
'keySet.2' => [ | ||
'__root__' => 'order_items contains both missing and extra keys', | ||
'product_title' => 'product_title must be present', | ||
'quantity' => 'quantity must be present', | ||
'product_title2' => 'product_title2 must not be present', | ||
], | ||
], | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--FILE-- | ||
<?php | ||
|
||
use Respect\Validation\Rules\Core\Simple; | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
exceptionAll('https://github.com/Respect/Validation/issues/1477', static function (): void { | ||
v::key( | ||
'Address', | ||
(new class extends Simple { | ||
protected function isValid(mixed $input): bool | ||
{ | ||
return false; | ||
} | ||
})->setTemplate('{{name}} is not good!') | ||
)->assert(['Address' => 'cvejvn']); | ||
}); | ||
|
||
?> | ||
--EXPECT-- | ||
https://github.com/Respect/Validation/issues/1477 | ||
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ | ||
Address is not good! | ||
- Address is not good! | ||
[ | ||
'Address' => 'Address is not good!', | ||
] |