44 lines
929 B
PHP
44 lines
929 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Respect/Validation.
|
|
*
|
|
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
|
|
*
|
|
* For the full copyright and license information, please view the "LICENSE.md"
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
/**
|
|
* @group rule
|
|
* @covers Respect\Validation\Rules\Regex
|
|
*/
|
|
final class RegexTest extends RuleTestCase
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function providerForValidInput()
|
|
{
|
|
return [
|
|
[new Regex('/^[a-z]+$/'), 'wpoiur'],
|
|
[new Regex('/^[a-z]+$/i'), 'wPoiur'],
|
|
[new Regex('/^[0-9]+$/i'), 42],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function providerForInvalidInput()
|
|
{
|
|
return [
|
|
[new Regex('/^w+$/'), 'w poiur'],
|
|
[new Regex('/^w+$/'), new \stdClass()],
|
|
[new Regex('/^w+$/'), []],
|
|
];
|
|
}
|
|
}
|