respect-validation/tests/unit/Rules/RegexTest.php
Danilo Correa 54293d4ca2
Apply contribution guidelines to "Regex" rule
Because some classes extend the "Regex" class this commit will also
change the implementation of those classes to use "Regex" by composition
instead of extending the class.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-14 00:15:03 +01:00

52 lines
1.1 KiB
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.
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use Respect\Validation\Test\RuleTestCase;
use stdClass;
/**
* @group rule
*
* @covers \Respect\Validation\Rules\Regex
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class RegexTest extends RuleTestCase
{
/**
* {@inheritdoc}
*/
public function providerForValidInput(): array
{
return [
[new Regex('/^[a-z]+$/'), 'wpoiur'],
[new Regex('/^[a-z]+$/i'), 'wPoiur'],
[new Regex('/^[0-9]+$/i'), 42],
];
}
/**
* {@inheritdoc}
*/
public function providerForInvalidInput(): array
{
return [
[new Regex('/^w+$/'), 'w poiur'],
[new Regex('/^w+$/'), new stdClass()],
[new Regex('/^w+$/'), []],
];
}
}