Skip to content

Commit

Permalink
added test for unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 17, 2020
1 parent dfce68e commit db05f01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Schema/Expect.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @method static Type array($default = [])
* @method static Type list($default = [])
* @method static Type mixed($default = null)
* @method static Type email($default = null)
* @method static Type unicode($default = null)
*/
final class Expect
{
Expand Down
16 changes: 16 additions & 0 deletions tests/Schema/Expect.minmax.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ test('string', function () {
});


test('unicode', function () {
$schema = Expect::unicode()->min(2)->max(4);

Assert::same('žšáé', (new Processor)->process($schema, 'žšáé'));
Assert::same('žš', (new Processor)->process($schema, 'žš'));

checkValidationErrors(function () use ($schema) {
(new Processor)->process($schema, 'ž');
}, ["The option expects to be unicode in range 2..4, string 'ž' given."]);

checkValidationErrors(function () use ($schema) {
(new Processor)->process($schema, 'žšáéx');
}, ["The option expects to be unicode in range 2..4, string 'žšáéx' given."]);
});


test('array', function () {
$schema = Expect::array()->min(1)->max(3);

Expand Down

0 comments on commit db05f01

Please sign in to comment.