2013-01-20 19:01:34 +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 19:01:34 +01:00
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
|
2019-02-07 13:15:15 +01:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
|
|
|
use stdClass;
|
2017-11-04 11:21:40 +01:00
|
|
|
|
2015-08-16 20:00:05 +02:00
|
|
|
/**
|
2019-02-07 13:15:15 +01:00
|
|
|
* @group rule
|
|
|
|
*
|
2018-09-24 21:48:41 +02:00
|
|
|
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
2019-05-11 19:30:47 +02:00
|
|
|
* @covers \Respect\Validation\Rules\Control
|
2018-11-25 17:56:04 +01:00
|
|
|
*
|
|
|
|
* @author Andre Ramaciotti <andre@ramaciotti.com>
|
|
|
|
* @author Gabriel Caruso <carusogabriel34@gmail.com>
|
|
|
|
* @author Henrique Moody <henriquemoody@gmail.com>
|
|
|
|
* @author Nick Lombard <github@jigsoft.co.za>
|
|
|
|
* @author Pascal Borreli <pascal@borreli.com>
|
2015-08-16 20:00:05 +02:00
|
|
|
*/
|
2019-05-11 19:30:47 +02:00
|
|
|
final class ControlTest extends RuleTestCase
|
2013-01-20 19:01:34 +01:00
|
|
|
{
|
|
|
|
/**
|
2019-04-05 14:33:00 +02:00
|
|
|
* {@inheritDoc}
|
2013-01-20 19:01:34 +01:00
|
|
|
*/
|
2023-04-02 16:00:37 +02:00
|
|
|
public static function providerForValidInput(): array
|
2013-01-20 19:01:34 +01:00
|
|
|
{
|
2019-05-11 19:30:47 +02:00
|
|
|
$sut = new Control();
|
2013-01-20 19:01:34 +01:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2019-05-11 19:30:47 +02:00
|
|
|
'\n' => [$sut, "\n"],
|
|
|
|
'\r' => [$sut, "\r"],
|
|
|
|
'\t' => [$sut, "\t"],
|
|
|
|
'\n\r\t' => [$sut, "\n\r\t"],
|
|
|
|
'Ignoring all characters' => [new Control('!@#$%^&*(){} '), '!@#$%^&*(){} '],
|
|
|
|
'Ignoring some characters' => [new Control('[]?+=/\\-_|"\',<>. '), "[]?+=/\\-_|\"',<>. \t \n"],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2013-02-22 19:53:28 +01:00
|
|
|
}
|
|
|
|
|
2019-02-07 21:22:10 +01:00
|
|
|
/**
|
2019-04-05 14:33:00 +02:00
|
|
|
* {@inheritDoc}
|
2019-02-07 21:22:10 +01:00
|
|
|
*/
|
2023-04-02 16:00:37 +02:00
|
|
|
public static function providerForInvalidInput(): array
|
2013-01-20 19:01:34 +01:00
|
|
|
{
|
2019-05-11 19:30:47 +02:00
|
|
|
$sut = new Control();
|
2013-01-20 19:01:34 +01:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2019-05-11 19:30:47 +02:00
|
|
|
'empty parameter' => [$sut, ''],
|
|
|
|
'16-50' => [$sut, '16-50'],
|
|
|
|
'a' => [$sut, 'a'],
|
|
|
|
'white space' => [$sut, ' '],
|
|
|
|
'Foo' => [$sut, 'Foo'],
|
|
|
|
'12.1' => [$sut, '12.1'],
|
|
|
|
'"-12"' => [$sut, '-12'],
|
|
|
|
'-12' => [$sut, -12],
|
|
|
|
'alganet' => [$sut, 'alganet'],
|
|
|
|
'empty array parameter' => [$sut, []],
|
|
|
|
'object' => [$sut, new stdClass()],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2013-01-20 19:01:34 +01:00
|
|
|
}
|
|
|
|
}
|