mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 07:15:45 +01:00
40 lines
990 B
PHP
40 lines
990 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use Respect\Validation\Test\RuleTestCase;
|
|
use stdClass;
|
|
|
|
#[Group('rule')]
|
|
#[CoversClass(Regex::class)]
|
|
final class RegexTest extends RuleTestCase
|
|
{
|
|
/** @return iterable<array{Regex, mixed}> */
|
|
public static function providerForValidInput(): iterable
|
|
{
|
|
return [
|
|
[new Regex('/^[a-z]+$/'), 'wpoiur'],
|
|
[new Regex('/^[a-z]+$/i'), 'wPoiur'],
|
|
[new Regex('/^[0-9]+$/i'), 42],
|
|
];
|
|
}
|
|
|
|
/** @return iterable<array{Regex, mixed}> */
|
|
public static function providerForInvalidInput(): iterable
|
|
{
|
|
return [
|
|
[new Regex('/^w+$/'), 'w poiur'],
|
|
[new Regex('/^w+$/'), new stdClass()],
|
|
[new Regex('/^w+$/'), []],
|
|
];
|
|
}
|
|
}
|