mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
This change will bring many breaking changes. The good thing is that we can finally use more modern resources available in PHP. I can imagine that's not a popular change since it will bring many breaking changes to users, but we shouldn't be stuck in time because of that. Using some of those features will make it easier to contribute to the project. At least, I hope so. There are still some useless doc-blocks, and we're not using "readonly" properties when we could. I aim to send those changes soon. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
|
use Respect\Validation\Test\Stubs\ToStringStub;
|
|
use stdClass;
|
|
|
|
use function tmpfile;
|
|
|
|
/**
|
|
* @group rule
|
|
* @covers \Respect\Validation\Rules\StringVal
|
|
*/
|
|
final class StringValTest extends RuleTestCase
|
|
{
|
|
/**
|
|
* @return array<array{StringVal, mixed}>
|
|
*/
|
|
public static function providerForValidInput(): array
|
|
{
|
|
$rule = new StringVal();
|
|
|
|
return [
|
|
[$rule, '6'],
|
|
[$rule, 'String'],
|
|
[$rule, 1.0],
|
|
[$rule, 42],
|
|
[$rule, false],
|
|
[$rule, true],
|
|
[$rule, new ToStringStub('something')],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<array{StringVal, mixed}>
|
|
*/
|
|
public static function providerForInvalidInput(): array
|
|
{
|
|
$rule = new StringVal();
|
|
|
|
return [
|
|
[$rule, []],
|
|
[
|
|
$rule,
|
|
static function (): void {
|
|
},
|
|
],
|
|
[$rule, new stdClass()],
|
|
[$rule, null],
|
|
[$rule, tmpfile()],
|
|
];
|
|
}
|
|
}
|