mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
One this method should throw an exception when the input is not valid, returning `TRUE` when it succeeds is not really consistent.
70 lines
1.9 KiB
PHP
70 lines
1.9 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 PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @group rule
|
|
* @covers \Respect\Validation\Rules\Lowercase
|
|
* @covers \Respect\Validation\Exceptions\LowercaseException
|
|
*/
|
|
class LowercaseTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider providerForValidLowercase
|
|
*/
|
|
public function testValidLowercaseShouldReturnTrue($input): void
|
|
{
|
|
$lowercase = new Lowercase();
|
|
self::assertTrue($lowercase->__invoke($input));
|
|
self::assertTrue($lowercase->assert($input));
|
|
$lowercase->check($input);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForInvalidLowercase
|
|
* @expectedException \Respect\Validation\Exceptions\LowercaseException
|
|
*/
|
|
public function testInvalidLowercaseShouldThrowException($input): void
|
|
{
|
|
$lowercase = new Lowercase();
|
|
self::assertFalse($lowercase->__invoke($input));
|
|
self::assertFalse($lowercase->assert($input));
|
|
}
|
|
|
|
public function providerForValidLowercase()
|
|
{
|
|
return [
|
|
[''],
|
|
['lowercase'],
|
|
['lowercase-with-dashes'],
|
|
['lowercase with spaces'],
|
|
['lowercase with numbers 123'],
|
|
['lowercase with specials characters like ã ç ê'],
|
|
['with specials characters like # $ % & * +'],
|
|
['τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός'],
|
|
];
|
|
}
|
|
|
|
public function providerForInvalidLowercase()
|
|
{
|
|
return [
|
|
['UPPERCASE'],
|
|
['CamelCase'],
|
|
['First Character Uppercase'],
|
|
['With Numbers 1 2 3'],
|
|
];
|
|
}
|
|
}
|