2013-01-20 20:59:33 +01:00
|
|
|
<?php
|
2015-06-08 16:47:14 +02:00
|
|
|
|
2015-06-08 17:09:25 +02:00
|
|
|
/*
|
2023-02-17 05:13:51 +01:00
|
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
|
|
* SPDX-License-Identifier: MIT
|
2015-06-08 17:09:25 +02:00
|
|
|
*/
|
|
|
|
|
2017-11-19 19:01:31 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2013-01-20 20:59:33 +01:00
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2019-03-03 22:33:10 +01:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
2017-11-04 11:21:40 +01:00
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
#[Group('rule')]
|
|
|
|
#[CoversClass(Space::class)]
|
2019-03-03 22:33:10 +01:00
|
|
|
final class SpaceTest extends RuleTestCase
|
2013-01-20 20:59:33 +01:00
|
|
|
{
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{Space, mixed}> */
|
|
|
|
public static function providerForValidInput(): iterable
|
2013-01-20 20:59:33 +01:00
|
|
|
{
|
2019-03-03 22:33:10 +01:00
|
|
|
$sut = new Space();
|
2013-01-20 20:59:33 +01:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2019-03-03 22:33:10 +01:00
|
|
|
'new line' => [$sut, "\n"],
|
|
|
|
'1 space' => [$sut, ' '],
|
|
|
|
'4 spaces' => [$sut, ' '],
|
|
|
|
'tab' => [$sut, "\t"],
|
|
|
|
'2 spaces' => [$sut, ' '],
|
|
|
|
'characters "!@#$%^&*(){} "' => [new Space('!@#$%^&*(){}'), '!@#$%^&*(){} '],
|
|
|
|
'characters "[]?+=/\\-_|\"\',<>. \t \n "' => [new Space('[]?+=/\\-_|"\',<>.'), "[]?+=/\\-_|\"',<>. \t \n "],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2013-02-22 19:53:28 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{Space, mixed}> */
|
|
|
|
public static function providerForInvalidInput(): iterable
|
2013-01-20 20:59:33 +01:00
|
|
|
{
|
2019-03-03 22:33:10 +01:00
|
|
|
$sut = new Space();
|
2013-01-20 20:59:33 +01:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2019-03-03 22:33:10 +01:00
|
|
|
'string empty' => [$sut, ''],
|
|
|
|
'string 16-56' => [$sut, '16-50'],
|
|
|
|
'string a' => [$sut, 'a'],
|
|
|
|
'string Foo' => [$sut, 'Foo'],
|
|
|
|
'string negative float' => [$sut, '12.1'],
|
|
|
|
'string negative number' => [$sut, '-12'],
|
|
|
|
'negative number ' => [$sut, -12],
|
|
|
|
'underline' => [$sut, '_'],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2013-01-20 20:59:33 +01:00
|
|
|
}
|
|
|
|
}
|