mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 08:42:15 +02:00
Make data providers static
From PHPUnit 10, all data providers need to be static. This commit will make migrating from version 9 to 10 a bit easier. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
ebcf247187
commit
2ee7509c2e
|
@ -157,7 +157,7 @@ final class HelloWorldTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new HelloWorld();
|
$rule = new HelloWorld();
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ final class HelloWorldTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new HelloWorld();
|
$rule = new HelloWorld();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ trait UndefinedProvider
|
||||||
*
|
*
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForUndefined(): array
|
public static function providerForUndefined(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[null],
|
[null],
|
||||||
|
@ -34,7 +34,7 @@ trait UndefinedProvider
|
||||||
*
|
*
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForNotUndefined(): array
|
public static function providerForNotUndefined(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[0],
|
[0],
|
||||||
|
|
|
@ -40,7 +40,7 @@ abstract class RuleTestCase extends TestCase
|
||||||
*
|
*
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
abstract public function providerForValidInput(): array;
|
abstract public static function providerForValidInput(): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data providers for invalid results.
|
* Data providers for invalid results.
|
||||||
|
@ -52,7 +52,7 @@ abstract class RuleTestCase extends TestCase
|
||||||
*
|
*
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
abstract public function providerForInvalidInput(): array;
|
abstract public static function providerForInvalidInput(): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
|
|
|
@ -27,10 +27,30 @@ use function sprintf;
|
||||||
*/
|
*/
|
||||||
final class CheckExceptionsTest extends TestCase
|
final class CheckExceptionsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider provideListOfRuleNames
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function ruleHasAnExceptionWhichHasValidApi(string $ruleName): void
|
||||||
|
{
|
||||||
|
$exceptionClass = 'Respect\\Validation\\Exceptions\\' . $ruleName . 'Exception';
|
||||||
|
self::assertTrue(
|
||||||
|
class_exists($exceptionClass),
|
||||||
|
sprintf('Expected exception class to exist: %s.', $ruleName)
|
||||||
|
);
|
||||||
|
|
||||||
|
$reflectionClass = new ReflectionClass($exceptionClass);
|
||||||
|
self::assertTrue(
|
||||||
|
$reflectionClass->isSubclassOf(ValidationException::class),
|
||||||
|
'Every Respect/Validation exception must extend ValidationException.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[][]
|
* @return string[][]
|
||||||
*/
|
*/
|
||||||
public function provideListOfRuleNames(): array
|
public static function provideListOfRuleNames(): array
|
||||||
{
|
{
|
||||||
$rulesDirectory = 'library/Rules';
|
$rulesDirectory = 'library/Rules';
|
||||||
$rulesDirectoryIterator = new DirectoryIterator($rulesDirectory);
|
$rulesDirectoryIterator = new DirectoryIterator($rulesDirectory);
|
||||||
|
@ -60,24 +80,4 @@ final class CheckExceptionsTest extends TestCase
|
||||||
|
|
||||||
return $ruleNames;
|
return $ruleNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provideListOfRuleNames
|
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function ruleHasAnExceptionWhichHasValidApi(string $ruleName): void
|
|
||||||
{
|
|
||||||
$exceptionClass = 'Respect\\Validation\\Exceptions\\' . $ruleName . 'Exception';
|
|
||||||
self::assertTrue(
|
|
||||||
class_exists($exceptionClass),
|
|
||||||
sprintf('Expected exception class to exist: %s.', $ruleName)
|
|
||||||
);
|
|
||||||
|
|
||||||
$reflectionClass = new ReflectionClass($exceptionClass);
|
|
||||||
self::assertTrue(
|
|
||||||
$reflectionClass->isSubclassOf(ValidationException::class),
|
|
||||||
'Every Respect/Validation exception must extend ValidationException.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,30 @@ final class CanValidateDateTimeTest extends TestCase
|
||||||
{
|
{
|
||||||
use CanValidateDateTime;
|
use CanValidateDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*
|
||||||
|
* @dataProvider providerForValidDateTime
|
||||||
|
*/
|
||||||
|
public function shouldFindWhenValueIsDateTime(string $format, string $value): void
|
||||||
|
{
|
||||||
|
self::assertTrue($this->isDateTime($format, $value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*
|
||||||
|
* @dataProvider providerForInvalidDateTime
|
||||||
|
*/
|
||||||
|
public function shouldFindWhenValueIsNotDateTime(string $format, string $value): void
|
||||||
|
{
|
||||||
|
self::assertFalse($this->isDateTime($format, $value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForValidDateTime(): array
|
public static function providerForValidDateTime(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['Y-m-d', '2009-09-09'],
|
['Y-m-d', '2009-09-09'],
|
||||||
|
@ -39,20 +59,10 @@ final class CanValidateDateTimeTest extends TestCase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @dataProvider providerForValidDateTime
|
|
||||||
*/
|
|
||||||
public function shouldFindWhenValueIsDateTime(string $format, string $value): void
|
|
||||||
{
|
|
||||||
self::assertTrue($this->isDateTime($format, $value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidDateTime(): array
|
public static function providerForInvalidDateTime(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['Y-m-d', '0000-01-01'],
|
['Y-m-d', '0000-01-01'],
|
||||||
|
@ -63,14 +73,4 @@ final class CanValidateDateTimeTest extends TestCase
|
||||||
['Y-m-d H:i:s', '1987-12-31'],
|
['Y-m-d H:i:s', '1987-12-31'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @dataProvider providerForInvalidDateTime
|
|
||||||
*/
|
|
||||||
public function shouldFindWhenValueIsNotDateTime(string $format, string $value): void
|
|
||||||
{
|
|
||||||
self::assertFalse($this->isDateTime($format, $value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,6 @@ use Respect\Validation\Test\TestCase;
|
||||||
*/
|
*/
|
||||||
final class AbstractRuleTest extends TestCase
|
final class AbstractRuleTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @return bool[][]
|
|
||||||
*/
|
|
||||||
public function providerForTrueAndFalse(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[true],
|
|
||||||
[false],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerForTrueAndFalse
|
* @dataProvider providerForTrueAndFalse
|
||||||
* @covers \Respect\Validation\Rules\AbstractRule::__invoke
|
* @covers \Respect\Validation\Rules\AbstractRule::__invoke
|
||||||
|
@ -195,4 +184,15 @@ final class AbstractRuleTest extends TestCase
|
||||||
|
|
||||||
self::assertSame($name, $abstractRuleMock->getName());
|
self::assertSame($name, $abstractRuleMock->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool[][]
|
||||||
|
*/
|
||||||
|
public static function providerForTrueAndFalse(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[true],
|
||||||
|
[false],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ final class AllOfTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @return Validatable[][]
|
* @return Validatable[][]
|
||||||
*/
|
*/
|
||||||
public function providerStaticDummyRules(): array
|
public static function providerStaticDummyRules(): array
|
||||||
{
|
{
|
||||||
$theInvalidOne = new Callback(static function () {
|
$theInvalidOne = new Callback(static function () {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class AlnumTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Alnum(), 'alganet'],
|
[new Alnum(), 'alganet'],
|
||||||
|
@ -53,7 +53,7 @@ final class AlnumTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Alnum(), ''],
|
[new Alnum(), ''],
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class AlphaTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'alphabetic' => [new Alpha(), 'alganet'],
|
'alphabetic' => [new Alpha(), 'alganet'],
|
||||||
|
@ -43,7 +43,7 @@ final class AlphaTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'empty string' => [new Alpha(), ''],
|
'empty string' => [new Alpha(), ''],
|
||||||
|
|
|
@ -23,10 +23,24 @@ use Respect\Validation\Test\TestCase;
|
||||||
*/
|
*/
|
||||||
final class AlwaysInvalidTest extends TestCase
|
final class AlwaysInvalidTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*
|
||||||
|
* @dataProvider providerForInvalidInput
|
||||||
|
*
|
||||||
|
* @param mixed $input
|
||||||
|
*/
|
||||||
|
public function itShouldAlwaysBeInvalid($input): void
|
||||||
|
{
|
||||||
|
$rule = new AlwaysInvalid();
|
||||||
|
|
||||||
|
self::assertFalse($rule->validate($input));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[0],
|
[0],
|
||||||
|
@ -40,18 +54,4 @@ final class AlwaysInvalidTest extends TestCase
|
||||||
[['array_full']],
|
[['array_full']],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @dataProvider providerForInvalidInput
|
|
||||||
*
|
|
||||||
* @param mixed $input
|
|
||||||
*/
|
|
||||||
public function itShouldAlwaysBeInvalid($input): void
|
|
||||||
{
|
|
||||||
$rule = new AlwaysInvalid();
|
|
||||||
|
|
||||||
self::assertFalse($rule->validate($input));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,24 @@ use Respect\Validation\Test\TestCase;
|
||||||
*/
|
*/
|
||||||
final class AlwaysValidTest extends TestCase
|
final class AlwaysValidTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*
|
||||||
|
* @dataProvider providerForValidInput
|
||||||
|
*
|
||||||
|
* @param mixed $input
|
||||||
|
*/
|
||||||
|
public function itAlwaysBeValid($input): void
|
||||||
|
{
|
||||||
|
$rule = new AlwaysValid();
|
||||||
|
|
||||||
|
self::assertTrue($rule->validate($input));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[0],
|
[0],
|
||||||
|
@ -40,18 +54,4 @@ final class AlwaysValidTest extends TestCase
|
||||||
[['array_full']],
|
[['array_full']],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @dataProvider providerForValidInput
|
|
||||||
*
|
|
||||||
* @param mixed $input
|
|
||||||
*/
|
|
||||||
public function itAlwaysBeValid($input): void
|
|
||||||
{
|
|
||||||
$rule = new AlwaysValid();
|
|
||||||
|
|
||||||
self::assertTrue($rule->validate($input));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class ArrayTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new ArrayType();
|
$rule = new ArrayType();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ final class ArrayTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new ArrayType();
|
$rule = new ArrayType();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class ArrayValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new ArrayVal();
|
$rule = new ArrayVal();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ final class ArrayValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new ArrayVal();
|
$rule = new ArrayVal();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ final class AttributeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'attribute is present without extra validator' => [new Attribute('public'), new WithProperties()],
|
'attribute is present without extra validator' => [new Attribute('public'), new WithProperties()],
|
||||||
|
@ -61,7 +61,7 @@ final class AttributeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'attribute is absent without extra validator' => [new Attribute('barr'), new WithProperties()],
|
'attribute is absent without extra validator' => [new Attribute('barr'), new WithProperties()],
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class Base64Test extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Base64();
|
$rule = new Base64();
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ final class Base64Test extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Base64();
|
$rule = new Base64();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class BaseTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Base(2), '011010001'],
|
[new Base(2), '011010001'],
|
||||||
|
@ -44,7 +44,7 @@ final class BaseTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Base(2), ''],
|
[new Base(2), ''],
|
||||||
|
|
|
@ -26,42 +26,6 @@ use Respect\Validation\Test\Stubs\CountableStub;
|
||||||
*/
|
*/
|
||||||
final class BetweenTest extends RuleTestCase
|
final class BetweenTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForValidInput(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[new Between(0, 1), 1],
|
|
||||||
[new Between(0, 1), 0],
|
|
||||||
[new Between(10, 20), 15],
|
|
||||||
[new Between(10, 20), 20],
|
|
||||||
[new Between(-10, 20), -5],
|
|
||||||
[new Between(-10, 20), 0],
|
|
||||||
[new Between('a', 'z'), 'j'],
|
|
||||||
[new Between(new DateTime('yesterday'), new DateTime('tomorrow')), new DateTime('now')],
|
|
||||||
[new Between(new CountableStub(1), new CountableStub(10)), 5],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForInvalidInput(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[new Between(10, 20), ''],
|
|
||||||
[new Between(10, 20), ''],
|
|
||||||
[new Between(0, 1), 2],
|
|
||||||
[new Between(0, 1), -1],
|
|
||||||
[new Between(10, 20), 999],
|
|
||||||
[new Between(-10, 20), -11],
|
|
||||||
[new Between('a', 'j'), 'z'],
|
|
||||||
[new Between(new DateTime('yesterday'), new DateTime('now')), new DateTime('tomorrow')],
|
|
||||||
[new Between(new CountableStub(1), new CountableStub(10)), 11],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
|
@ -81,4 +45,40 @@ final class BetweenTest extends RuleTestCase
|
||||||
|
|
||||||
new Between(5, 5);
|
new Between(5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForValidInput(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[new Between(0, 1), 1],
|
||||||
|
[new Between(0, 1), 0],
|
||||||
|
[new Between(10, 20), 15],
|
||||||
|
[new Between(10, 20), 20],
|
||||||
|
[new Between(-10, 20), -5],
|
||||||
|
[new Between(-10, 20), 0],
|
||||||
|
[new Between('a', 'z'), 'j'],
|
||||||
|
[new Between(new DateTime('yesterday'), new DateTime('tomorrow')), new DateTime('now')],
|
||||||
|
[new Between(new CountableStub(1), new CountableStub(10)), 5],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidInput(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[new Between(10, 20), ''],
|
||||||
|
[new Between(10, 20), ''],
|
||||||
|
[new Between(0, 1), 2],
|
||||||
|
[new Between(0, 1), -1],
|
||||||
|
[new Between(10, 20), 999],
|
||||||
|
[new Between(-10, 20), -11],
|
||||||
|
[new Between('a', 'j'), 'z'],
|
||||||
|
[new Between(new DateTime('yesterday'), new DateTime('now')), new DateTime('tomorrow')],
|
||||||
|
[new Between(new CountableStub(1), new CountableStub(10)), 11],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class BoolTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new BoolType();
|
$rule = new BoolType();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ final class BoolTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new BoolType();
|
$rule = new BoolType();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class BoolValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new BoolVal();
|
$rule = new BoolVal();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ final class BoolValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new BoolVal();
|
$rule = new BoolVal();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class BsnTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Bsn();
|
$rule = new Bsn();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ final class BsnTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Bsn();
|
$rule = new Bsn();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class CallableTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new CallableType();
|
$rule = new CallableType();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ final class CallableTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new CallableType();
|
$rule = new CallableType();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class CallbackTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Callback('is_a', 'stdClass'), new stdClass()],
|
[new Callback('is_a', 'stdClass'), new stdClass()],
|
||||||
|
@ -46,7 +46,7 @@ final class CallbackTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
|
|
@ -40,7 +40,7 @@ final class CharsetTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Charset('UTF-8'), ''],
|
[new Charset('UTF-8'), ''],
|
||||||
|
@ -57,7 +57,7 @@ final class CharsetTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Charset('ASCII');
|
$rule = new Charset('ASCII');
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class CnhTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Cnh();
|
$rule = new Cnh();
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ final class CnhTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Cnh();
|
$rule = new Cnh();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class CnpjTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Cnpj();
|
$rule = new Cnpj();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ final class CnpjTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Cnpj();
|
$rule = new Cnpj();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class ConsonantTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$consonant = new Consonant();
|
$consonant = new Consonant();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ final class ConsonantTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$consonant = new Consonant();
|
$consonant = new Consonant();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class ContainsAnyTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new ContainsAny(['Something', 'Else']), 'something else'],
|
[new ContainsAny(['Something', 'Else']), 'something else'],
|
||||||
|
@ -42,7 +42,7 @@ final class ContainsAnyTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new ContainsAny(['foo']), ['bar', 'baz']],
|
[new ContainsAny(['foo']), ['bar', 'baz']],
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class ContainsTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Contains('foo', false), ['bar', 'foo']],
|
[new Contains('foo', false), ['bar', 'foo']],
|
||||||
|
@ -48,7 +48,7 @@ final class ContainsTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Contains('foo', false), ''],
|
[new Contains('foo', false), ''],
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class ControlTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Control();
|
$sut = new Control();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ final class ControlTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Control();
|
$sut = new Control();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class CountableTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Countable();
|
$rule = new Countable();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ final class CountableTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Countable();
|
$rule = new Countable();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ final class CountryCodeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new CountryCode(CountryCode::ALPHA2), 'BR'],
|
[new CountryCode(CountryCode::ALPHA2), 'BR'],
|
||||||
|
@ -58,7 +58,7 @@ final class CountryCodeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new CountryCode(CountryCode::ALPHA2), 'USA'],
|
[new CountryCode(CountryCode::ALPHA2), 'USA'],
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class CpfTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Cpf();
|
$rule = new Cpf();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ final class CpfTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Cpf();
|
$rule = new Cpf();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ final class CreditCardTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$general = new CreditCard();
|
$general = new CreditCard();
|
||||||
$amex = new CreditCard(CreditCard::AMERICAN_EXPRESS);
|
$amex = new CreditCard(CreditCard::AMERICAN_EXPRESS);
|
||||||
|
@ -79,7 +79,7 @@ final class CreditCardTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$general = new CreditCard();
|
$general = new CreditCard();
|
||||||
$amex = new CreditCard(CreditCard::AMERICAN_EXPRESS);
|
$amex = new CreditCard(CreditCard::AMERICAN_EXPRESS);
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class CurrencyCodeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new CurrencyCode();
|
$rule = new CurrencyCode();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ final class CurrencyCodeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new CurrencyCode();
|
$rule = new CurrencyCode();
|
||||||
|
|
||||||
|
|
|
@ -24,58 +24,6 @@ use Respect\Validation\Test\RuleTestCase;
|
||||||
*/
|
*/
|
||||||
final class DateTest extends RuleTestCase
|
final class DateTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForValidInput(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[new Date(), '2017-12-31'],
|
|
||||||
[new Date('m/d/y'), '12/31/17'],
|
|
||||||
[new Date('F jS, Y'), 'May 1st, 2017'],
|
|
||||||
[new Date('Ydm'), 20173112],
|
|
||||||
[new Date(), '2020-02-29'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForInvalidInput(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[new Date(), 'not-a-date'],
|
|
||||||
[new Date(), []],
|
|
||||||
[new Date(), true],
|
|
||||||
[new Date(), false],
|
|
||||||
[new Date(), null],
|
|
||||||
[new Date(), ''],
|
|
||||||
[new Date(), '1988-02-30'],
|
|
||||||
[new Date('d/m/y'), '12/31/17'],
|
|
||||||
[new Date(), '2019-02-29'],
|
|
||||||
[new Date(), new DateTime()],
|
|
||||||
[new Date(), new DateTimeImmutable()],
|
|
||||||
[new Date(), ''],
|
|
||||||
[new Date('Y-m-d'), '2009-12-00'],
|
|
||||||
[new Date('Y-m-d'), '2018-02-29'],
|
|
||||||
[new Date(), '2014-99'],
|
|
||||||
[new Date('d'), 1],
|
|
||||||
[new Date('Y-m'), '2014-99'],
|
|
||||||
[new Date('m'), '99'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[][]
|
|
||||||
*/
|
|
||||||
public function validFormatsProvider(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['Y-m-d H:i:s'],
|
|
||||||
['c'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*
|
*
|
||||||
|
@ -99,4 +47,56 @@ final class DateTest extends RuleTestCase
|
||||||
|
|
||||||
self::assertSame($format, $exception->getParam('format'));
|
self::assertSame($format, $exception->getParam('format'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[][]
|
||||||
|
*/
|
||||||
|
public static function validFormatsProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['Y-m-d H:i:s'],
|
||||||
|
['c'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForValidInput(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[new Date(), '2017-12-31'],
|
||||||
|
[new Date('m/d/y'), '12/31/17'],
|
||||||
|
[new Date('F jS, Y'), 'May 1st, 2017'],
|
||||||
|
[new Date('Ydm'), 20173112],
|
||||||
|
[new Date(), '2020-02-29'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidInput(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[new Date(), 'not-a-date'],
|
||||||
|
[new Date(), []],
|
||||||
|
[new Date(), true],
|
||||||
|
[new Date(), false],
|
||||||
|
[new Date(), null],
|
||||||
|
[new Date(), ''],
|
||||||
|
[new Date(), '1988-02-30'],
|
||||||
|
[new Date('d/m/y'), '12/31/17'],
|
||||||
|
[new Date(), '2019-02-29'],
|
||||||
|
[new Date(), new DateTime()],
|
||||||
|
[new Date(), new DateTimeImmutable()],
|
||||||
|
[new Date(), ''],
|
||||||
|
[new Date('Y-m-d'), '2009-12-00'],
|
||||||
|
[new Date('Y-m-d'), '2018-02-29'],
|
||||||
|
[new Date(), '2014-99'],
|
||||||
|
[new Date('d'), 1],
|
||||||
|
[new Date('Y-m'), '2014-99'],
|
||||||
|
[new Date('m'), '99'],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,60 @@ use function date_default_timezone_set;
|
||||||
*/
|
*/
|
||||||
final class DateTimeTest extends RuleTestCase
|
final class DateTimeTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function shouldPassFormatToParameterToException(): void
|
||||||
|
{
|
||||||
|
$format = 'F jS, Y';
|
||||||
|
$equals = new DateTime($format);
|
||||||
|
$exception = $equals->reportError('input');
|
||||||
|
|
||||||
|
self::assertSame($format, $exception->getParam('format'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datetime strings with timezone information are valid independent on the
|
||||||
|
* system's timezone setting.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*
|
||||||
|
* @dataProvider providerForDateTimeWithTimezone
|
||||||
|
*/
|
||||||
|
public function shouldValidateNoMatterTimezone(string $format, string $input, string $timezone): void
|
||||||
|
{
|
||||||
|
$currentTimezone = date_default_timezone_get();
|
||||||
|
|
||||||
|
date_default_timezone_set($timezone);
|
||||||
|
|
||||||
|
$rule = new DateTime($format);
|
||||||
|
|
||||||
|
self::assertTrue($rule->validate($input));
|
||||||
|
|
||||||
|
date_default_timezone_set($currentTimezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed[][]
|
||||||
|
*/
|
||||||
|
public static function providerForDateTimeWithTimezone(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['c', '2004-02-12T15:19:21+00:00', 'Europe/Amsterdam'],
|
||||||
|
['c', '2004-02-12T15:19:21+00:00', 'UTC'],
|
||||||
|
['d/m/Y', '23/05/1987', 'Europe/Amsterdam'],
|
||||||
|
['d/m/Y', '23/05/1987', 'UTC'],
|
||||||
|
['r', 'Thu, 29 Dec 2005 01:02:03 +0000', 'Europe/Amsterdam'],
|
||||||
|
['r', 'Thu, 29 Dec 2005 01:02:03 +0000', 'UTC'],
|
||||||
|
['Ym', '202302', 'Europe/Amsterdam'],
|
||||||
|
['Ym', '202302', 'UTC'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new DateTime(), 'now'],
|
[new DateTime(), 'now'],
|
||||||
|
@ -58,7 +108,7 @@ final class DateTimeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new DateTime(), 'not-a-date'],
|
[new DateTime(), 'not-a-date'],
|
||||||
|
@ -75,54 +125,4 @@ final class DateTimeTest extends RuleTestCase
|
||||||
[new DateTime('Y-m-d H:i:s'), '21-3-123:12:01'],
|
[new DateTime('Y-m-d H:i:s'), '21-3-123:12:01'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldPassFormatToParameterToException(): void
|
|
||||||
{
|
|
||||||
$format = 'F jS, Y';
|
|
||||||
$equals = new DateTime($format);
|
|
||||||
$exception = $equals->reportError('input');
|
|
||||||
|
|
||||||
self::assertSame($format, $exception->getParam('format'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed[][]
|
|
||||||
*/
|
|
||||||
public function providerForDateTimeWithTimezone(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['c', '2004-02-12T15:19:21+00:00', 'Europe/Amsterdam'],
|
|
||||||
['c', '2004-02-12T15:19:21+00:00', 'UTC'],
|
|
||||||
['d/m/Y', '23/05/1987', 'Europe/Amsterdam'],
|
|
||||||
['d/m/Y', '23/05/1987', 'UTC'],
|
|
||||||
['r', 'Thu, 29 Dec 2005 01:02:03 +0000', 'Europe/Amsterdam'],
|
|
||||||
['r', 'Thu, 29 Dec 2005 01:02:03 +0000', 'UTC'],
|
|
||||||
['Ym', '202302', 'Europe/Amsterdam'],
|
|
||||||
['Ym', '202302', 'UTC'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Datetime strings with timezone information are valid independent on the
|
|
||||||
* system's timezone setting.
|
|
||||||
*
|
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @dataProvider providerForDateTimeWithTimezone
|
|
||||||
*/
|
|
||||||
public function shouldValidateNoMatterTimezone(string $format, string $input, string $timezone): void
|
|
||||||
{
|
|
||||||
$currentTimezone = date_default_timezone_get();
|
|
||||||
|
|
||||||
date_default_timezone_set($timezone);
|
|
||||||
|
|
||||||
$rule = new DateTime($format);
|
|
||||||
|
|
||||||
self::assertTrue($rule->validate($input));
|
|
||||||
|
|
||||||
date_default_timezone_set($currentTimezone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ final class DecimalTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Decimal(0), 1],
|
[new Decimal(0), 1],
|
||||||
|
@ -56,7 +56,7 @@ final class DecimalTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Decimal(1), '1.50'],
|
[new Decimal(1), '1.50'],
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class DigitTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'positive integer' => [new Digit(), 165],
|
'positive integer' => [new Digit(), 165],
|
||||||
|
@ -47,7 +47,7 @@ final class DigitTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'empty' => [new Digit(), ''],
|
'empty' => [new Digit(), ''],
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class DirectoryTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Directory();
|
$rule = new Directory();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ final class DirectoryTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Directory();
|
$rule = new Directory();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class DomainTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Domain(false), '111111111111domain.local'],
|
[new Domain(false), '111111111111domain.local'],
|
||||||
|
@ -46,7 +46,7 @@ final class DomainTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Domain(), null],
|
[new Domain(), null],
|
||||||
|
|
|
@ -30,40 +30,6 @@ use function range;
|
||||||
*/
|
*/
|
||||||
final class EachTest extends RuleTestCase
|
final class EachTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForValidInput(): array
|
|
||||||
{
|
|
||||||
$rule = new Each(new AlwaysValid());
|
|
||||||
|
|
||||||
return [
|
|
||||||
[$rule, []],
|
|
||||||
[$rule, [1, 2, 3, 4, 5]],
|
|
||||||
[$rule, $this->createTraversableInput(1, 5)],
|
|
||||||
[$rule, $this->createStdClassInput(1, 5)],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForInvalidInput(): array
|
|
||||||
{
|
|
||||||
$rule = new Each(new AlwaysInvalid());
|
|
||||||
|
|
||||||
return [
|
|
||||||
[$rule, 123],
|
|
||||||
[$rule, ''],
|
|
||||||
[$rule, null],
|
|
||||||
[$rule, false],
|
|
||||||
[$rule, ['', 2, 3, 4, 5]],
|
|
||||||
[$rule, ['a', 2, 3, 4, 5]],
|
|
||||||
[$rule, $this->createTraversableInput(1, 5)],
|
|
||||||
[$rule, $this->createStdClassInput(1, 5)],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
|
@ -114,10 +80,44 @@ final class EachTest extends RuleTestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForValidInput(): array
|
||||||
|
{
|
||||||
|
$rule = new Each(new AlwaysValid());
|
||||||
|
|
||||||
|
return [
|
||||||
|
[$rule, []],
|
||||||
|
[$rule, [1, 2, 3, 4, 5]],
|
||||||
|
[$rule, self::createTraversableInput(1, 5)],
|
||||||
|
[$rule, self::createStdClassInput(1, 5)],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidInput(): array
|
||||||
|
{
|
||||||
|
$rule = new Each(new AlwaysInvalid());
|
||||||
|
|
||||||
|
return [
|
||||||
|
[$rule, 123],
|
||||||
|
[$rule, ''],
|
||||||
|
[$rule, null],
|
||||||
|
[$rule, false],
|
||||||
|
[$rule, ['', 2, 3, 4, 5]],
|
||||||
|
[$rule, ['a', 2, 3, 4, 5]],
|
||||||
|
[$rule, self::createTraversableInput(1, 5)],
|
||||||
|
[$rule, self::createStdClassInput(1, 5)],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Traversable<int>
|
* @return Traversable<int>
|
||||||
*/
|
*/
|
||||||
private function createTraversableInput(int $firstValue, int $lastValue): Traversable
|
private static function createTraversableInput(int $firstValue, int $lastValue): Traversable
|
||||||
{
|
{
|
||||||
/** @var SplStack<int> */
|
/** @var SplStack<int> */
|
||||||
$input = new SplStack();
|
$input = new SplStack();
|
||||||
|
@ -128,7 +128,7 @@ final class EachTest extends RuleTestCase
|
||||||
return $input;
|
return $input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createStdClassInput(int $firstValue, int $lastValue): stdClass
|
private static function createStdClassInput(int $firstValue, int $lastValue): stdClass
|
||||||
{
|
{
|
||||||
$input = [];
|
$input = [];
|
||||||
foreach (range($firstValue, $lastValue) as $value) {
|
foreach (range($firstValue, $lastValue) as $value) {
|
||||||
|
|
|
@ -54,9 +54,9 @@ final class EmailTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = $this->createSutWithoutEmailValidator();
|
$sut = self::sut();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[$sut, 'test@test.com'],
|
[$sut, 'test@test.com'],
|
||||||
|
@ -69,9 +69,9 @@ final class EmailTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = $this->createSutWithoutEmailValidator();
|
$sut = self::sut();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[$sut, ''],
|
[$sut, ''],
|
||||||
|
@ -94,7 +94,7 @@ final class EmailTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
private function createSutWithoutEmailValidator(): Email
|
private static function sut(): Email
|
||||||
{
|
{
|
||||||
$rule = new Email();
|
$rule = new Email();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class EndsWithTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new EndsWith('foo'), ['bar', 'foo']],
|
[new EndsWith('foo'), ['bar', 'foo']],
|
||||||
|
@ -42,7 +42,7 @@ final class EndsWithTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new EndsWith('foo'), ''],
|
[new EndsWith('foo'), ''],
|
||||||
|
|
|
@ -22,10 +22,22 @@ use stdClass;
|
||||||
*/
|
*/
|
||||||
final class EqualsTest extends RuleTestCase
|
final class EqualsTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function shouldPassCompareToParameterToException(): void
|
||||||
|
{
|
||||||
|
$compareTo = new stdClass();
|
||||||
|
$equals = new Equals($compareTo);
|
||||||
|
$exception = $equals->reportError('input');
|
||||||
|
|
||||||
|
self::assertSame($compareTo, $exception->getParam('compareTo'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Equals('foo'), 'foo'],
|
[new Equals('foo'), 'foo'],
|
||||||
|
@ -39,23 +51,11 @@ final class EqualsTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Equals('foo'), ''],
|
[new Equals('foo'), ''],
|
||||||
[new Equals('foo'), 'bar'],
|
[new Equals('foo'), 'bar'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldPassCompareToParameterToException(): void
|
|
||||||
{
|
|
||||||
$compareTo = new stdClass();
|
|
||||||
$equals = new Equals($compareTo);
|
|
||||||
$exception = $equals->reportError('input');
|
|
||||||
|
|
||||||
self::assertSame($compareTo, $exception->getParam('compareTo'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class EquivalentTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Equivalent(1), true],
|
[new Equivalent(1), true],
|
||||||
|
@ -38,7 +38,7 @@ final class EquivalentTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Equivalent(1), false],
|
[new Equivalent(1), false],
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class EvenTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Even(), 2],
|
[new Even(), 2],
|
||||||
|
@ -41,7 +41,7 @@ final class EvenTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Even(), ''],
|
[new Even(), ''],
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class ExecutableTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Executable();
|
$rule = new Executable();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ final class ExecutableTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Executable();
|
$rule = new Executable();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class ExistsTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Exists();
|
$rule = new Exists();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ final class ExistsTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Exists();
|
$rule = new Exists();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class ExtensionTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'txt' => [new Extension('txt'), 'filename.txt'],
|
'txt' => [new Extension('txt'), 'filename.txt'],
|
||||||
|
@ -42,7 +42,7 @@ final class ExtensionTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'jpg' => [new Extension('jpg'), 'filename.txt'],
|
'jpg' => [new Extension('jpg'), 'filename.txt'],
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class FactorTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'1 is factor 1' => [new Factor(1), 1],
|
'1 is factor 1' => [new Factor(1), 1],
|
||||||
|
@ -69,7 +69,7 @@ final class FactorTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'3 is not factor 2' => [new Factor(3), 2],
|
'3 is not factor 2' => [new Factor(3), 2],
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class FalseValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new FalseVal();
|
$sut = new FalseVal();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ final class FalseValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new FalseVal();
|
$sut = new FalseVal();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class FibonacciTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Fibonacci();
|
$rule = new Fibonacci();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ final class FibonacciTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Fibonacci();
|
$rule = new Fibonacci();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class FileTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new File();
|
$sut = new File();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ final class FileTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new File();
|
$sut = new File();
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ final class FilterVarTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new FilterVar(FILTER_VALIDATE_INT), '12345'],
|
[new FilterVar(FILTER_VALIDATE_INT), '12345'],
|
||||||
|
@ -63,7 +63,7 @@ final class FilterVarTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new FilterVar(FILTER_VALIDATE_INT), 1.4],
|
[new FilterVar(FILTER_VALIDATE_INT), 1.4],
|
||||||
|
|
|
@ -31,7 +31,7 @@ final class FiniteTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Finite();
|
$sut = new Finite();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ final class FiniteTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Finite();
|
$sut = new Finite();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class FloatTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new FloatType();
|
$rule = new FloatType();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ final class FloatTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new FloatType();
|
$rule = new FloatType();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class FloatValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new FloatVal();
|
$rule = new FloatVal();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ final class FloatValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new FloatVal();
|
$rule = new FloatVal();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class GraphTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$graph = new Graph();
|
$graph = new Graph();
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ final class GraphTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$graph = new Graph();
|
$graph = new Graph();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class GreaterThanTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new GreaterThan(10), 11],
|
[new GreaterThan(10), 11],
|
||||||
|
@ -40,7 +40,7 @@ final class GreaterThanTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new GreaterThan(10), 9],
|
[new GreaterThan(10), 9],
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class HexRgbColorTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new HexRgbColor();
|
$sut = new HexRgbColor();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ final class HexRgbColorTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new HexRgbColor();
|
$sut = new HexRgbColor();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class IbanTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Iban();
|
$sut = new Iban();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ final class IbanTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Iban();
|
$sut = new Iban();
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,22 @@ use stdClass;
|
||||||
*/
|
*/
|
||||||
final class IdenticalTest extends RuleTestCase
|
final class IdenticalTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function shouldPassCompareToParameterToException(): void
|
||||||
|
{
|
||||||
|
$compareTo = new stdClass();
|
||||||
|
$rule = new Identical($compareTo);
|
||||||
|
$exception = $rule->reportError('input');
|
||||||
|
|
||||||
|
self::assertSame($compareTo, $exception->getParam('compareTo'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$object = new stdClass();
|
$object = new stdClass();
|
||||||
|
|
||||||
|
@ -40,7 +52,7 @@ final class IdenticalTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Identical(42), '42'],
|
[new Identical(42), '42'],
|
||||||
|
@ -50,16 +62,4 @@ final class IdenticalTest extends RuleTestCase
|
||||||
[new Identical(10), 10.0],
|
[new Identical(10), 10.0],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldPassCompareToParameterToException(): void
|
|
||||||
{
|
|
||||||
$compareTo = new stdClass();
|
|
||||||
$rule = new Identical($compareTo);
|
|
||||||
$exception = $rule->reportError('input');
|
|
||||||
|
|
||||||
self::assertSame($compareTo, $exception->getParam('compareTo'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,38 +25,6 @@ use SplFileObject;
|
||||||
*/
|
*/
|
||||||
final class ImageTest extends RuleTestCase
|
final class ImageTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForValidInput(): array
|
|
||||||
{
|
|
||||||
$rule = new Image();
|
|
||||||
|
|
||||||
return [
|
|
||||||
[$rule, self::fixture('valid-image.gif')],
|
|
||||||
[$rule, self::fixture('valid-image.jpg')],
|
|
||||||
[$rule, self::fixture('valid-image.png')],
|
|
||||||
[$rule, new SplFileInfo(self::fixture('valid-image.gif'))],
|
|
||||||
[$rule, new SplFileInfo(self::fixture('valid-image.jpg'))],
|
|
||||||
[$rule, new SplFileObject(self::fixture('valid-image.png'))],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForInvalidInput(): array
|
|
||||||
{
|
|
||||||
$rule = new Image();
|
|
||||||
|
|
||||||
return [
|
|
||||||
[$rule, self::fixture('invalid-image.png')],
|
|
||||||
[$rule, 'asdf'],
|
|
||||||
[$rule, 1],
|
|
||||||
[$rule, true],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
|
@ -75,4 +43,36 @@ final class ImageTest extends RuleTestCase
|
||||||
|
|
||||||
self::assertTrue($rule->validate($input));
|
self::assertTrue($rule->validate($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForValidInput(): array
|
||||||
|
{
|
||||||
|
$rule = new Image();
|
||||||
|
|
||||||
|
return [
|
||||||
|
[$rule, self::fixture('valid-image.gif')],
|
||||||
|
[$rule, self::fixture('valid-image.jpg')],
|
||||||
|
[$rule, self::fixture('valid-image.png')],
|
||||||
|
[$rule, new SplFileInfo(self::fixture('valid-image.gif'))],
|
||||||
|
[$rule, new SplFileInfo(self::fixture('valid-image.jpg'))],
|
||||||
|
[$rule, new SplFileObject(self::fixture('valid-image.png'))],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidInput(): array
|
||||||
|
{
|
||||||
|
$rule = new Image();
|
||||||
|
|
||||||
|
return [
|
||||||
|
[$rule, self::fixture('invalid-image.png')],
|
||||||
|
[$rule, 'asdf'],
|
||||||
|
[$rule, 1],
|
||||||
|
[$rule, true],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class ImeiTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Imei();
|
$rule = new Imei();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ final class ImeiTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Imei();
|
$rule = new Imei();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class InTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new In(''), ''],
|
[new In(''), ''],
|
||||||
|
@ -45,7 +45,7 @@ final class InTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new In('0'), null],
|
[new In('0'), null],
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class InfiniteTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Infinite();
|
$rule = new Infinite();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ final class InfiniteTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Infinite();
|
$rule = new Infinite();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ final class InstanceTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Instance(DateTime::class), new DateTime()],
|
[new Instance(DateTime::class), new DateTime()],
|
||||||
|
@ -44,7 +44,7 @@ final class InstanceTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Instance(DateTime::class), ''],
|
[new Instance(DateTime::class), ''],
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class IntTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new IntType();
|
$rule = new IntType();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ final class IntTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new IntType();
|
$rule = new IntType();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class IntValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new IntVal();
|
$rule = new IntVal();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ final class IntValTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new IntVal();
|
$rule = new IntVal();
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,40 @@ use const FILTER_FLAG_NO_PRIV_RANGE;
|
||||||
*/
|
*/
|
||||||
final class IpTest extends RuleTestCase
|
final class IpTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*
|
||||||
|
* @dataProvider providerForInvalidRanges
|
||||||
|
*
|
||||||
|
* @throws ComponentException
|
||||||
|
*/
|
||||||
|
public function invalidRangeShouldRaiseException(string $range): void
|
||||||
|
{
|
||||||
|
$this->expectException(ComponentException::class);
|
||||||
|
|
||||||
|
new Ip($range);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[][]
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidRanges(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['192.168'],
|
||||||
|
['asd'],
|
||||||
|
['192.168.0.0-192.168.0.256'],
|
||||||
|
['192.168.0.0-192.168.0.1/4'],
|
||||||
|
['192.168.0/1'],
|
||||||
|
['192.168.2.0/256.256.256.256'],
|
||||||
|
['192.168.2.0/8.256.256.256'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Ip('127.*'), '127.0.0.1'],
|
[new Ip('127.*'), '127.0.0.1'],
|
||||||
|
@ -61,7 +91,7 @@ final class IpTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Ip('127.*'), '192.0.1.0'],
|
[new Ip('127.*'), '192.0.1.0'],
|
||||||
|
@ -84,36 +114,6 @@ final class IpTest extends RuleTestCase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[][]
|
|
||||||
*/
|
|
||||||
public function providerForInvalidRanges(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['192.168'],
|
|
||||||
['asd'],
|
|
||||||
['192.168.0.0-192.168.0.256'],
|
|
||||||
['192.168.0.0-192.168.0.1/4'],
|
|
||||||
['192.168.0/1'],
|
|
||||||
['192.168.2.0/256.256.256.256'],
|
|
||||||
['192.168.2.0/8.256.256.256'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*
|
|
||||||
* @dataProvider providerForInvalidRanges
|
|
||||||
*
|
|
||||||
* @throws ComponentException
|
|
||||||
*/
|
|
||||||
public function invalidRangeShouldRaiseException(string $range): void
|
|
||||||
{
|
|
||||||
$this->expectException(ComponentException::class);
|
|
||||||
|
|
||||||
new Ip($range);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class IsbnTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Isbn();
|
$sut = new Isbn();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ final class IsbnTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new Isbn();
|
$sut = new Isbn();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class IterableTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new IterableType();
|
$rule = new IterableType();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ final class IterableTypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new IterableType();
|
$rule = new IterableType();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class JsonTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$json = new Json();
|
$json = new Json();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ final class JsonTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$json = new Json();
|
$json = new Json();
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ final class KeySetTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidArguments(): array
|
public static function providerForInvalidArguments(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[''],
|
[''],
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class KeyValueTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Equal values' => [new KeyValue('foo', 'equals', 'bar'), ['foo' => 42, 'bar' => 42]],
|
'Equal values' => [new KeyValue('foo', 'equals', 'bar'), ['foo' => 42, 'bar' => 42]],
|
||||||
|
@ -42,7 +42,7 @@ final class KeyValueTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$keyValue = new KeyValue('foo', 'equals', 'bar');
|
$keyValue = new KeyValue('foo', 'equals', 'bar');
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,20 @@ use Respect\Validation\Test\RuleTestCase;
|
||||||
*/
|
*/
|
||||||
final class LanguageCodeTest extends RuleTestCase
|
final class LanguageCodeTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function itShouldThrowAnExceptionWhenSetIsInvalid(): void
|
||||||
|
{
|
||||||
|
$this->expectExceptionObject(new ComponentException('"foo" is not a valid language set for ISO 639'));
|
||||||
|
|
||||||
|
new LanguageCode('foo');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sutAlpha2 = new LanguageCode(LanguageCode::ALPHA2);
|
$sutAlpha2 = new LanguageCode(LanguageCode::ALPHA2);
|
||||||
$sutAlpha3 = new LanguageCode(LanguageCode::ALPHA3);
|
$sutAlpha3 = new LanguageCode(LanguageCode::ALPHA3);
|
||||||
|
@ -47,7 +57,7 @@ final class LanguageCodeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sutAlpha2 = new LanguageCode(LanguageCode::ALPHA2);
|
$sutAlpha2 = new LanguageCode(LanguageCode::ALPHA2);
|
||||||
$sutAlpha3 = new LanguageCode(LanguageCode::ALPHA3);
|
$sutAlpha3 = new LanguageCode(LanguageCode::ALPHA3);
|
||||||
|
@ -65,14 +75,4 @@ final class LanguageCodeTest extends RuleTestCase
|
||||||
'alpha-3: null' => [$sutAlpha3, ''],
|
'alpha-3: null' => [$sutAlpha3, ''],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function itShouldThrowAnExceptionWhenSetIsInvalid(): void
|
|
||||||
{
|
|
||||||
$this->expectExceptionObject(new ComponentException('"foo" is not a valid language set for ISO 639'));
|
|
||||||
|
|
||||||
new LanguageCode('foo');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class LeapDateTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new LeapDate('Y-m-d'), '1988-02-29'],
|
[new LeapDate('Y-m-d'), '1988-02-29'],
|
||||||
|
@ -40,7 +40,7 @@ final class LeapDateTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new LeapDate('Y-m-d'), '1989-02-29'],
|
[new LeapDate('Y-m-d'), '1989-02-29'],
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class LeapYearTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new LeapYear();
|
$rule = new LeapYear();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ final class LeapYearTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new LeapYear();
|
$rule = new LeapYear();
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,21 @@ use function tmpfile;
|
||||||
*/
|
*/
|
||||||
final class LengthTest extends RuleTestCase
|
final class LengthTest extends RuleTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function isShouldNotNotAcceptInvalidLengths(): void
|
||||||
|
{
|
||||||
|
$this->expectException(ComponentException::class);
|
||||||
|
$this->expectExceptionMessage('10 cannot be less than 1 for validation');
|
||||||
|
|
||||||
|
new Length(10, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Length(1, 15), 'alganet'],
|
[new Length(1, 15), 'alganet'],
|
||||||
|
@ -56,7 +67,7 @@ final class LengthTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Length(1, 15), ''],
|
[new Length(1, 15), ''],
|
||||||
|
@ -72,15 +83,4 @@ final class LengthTest extends RuleTestCase
|
||||||
[new Length(1, 4), 12345],
|
[new Length(1, 4), 12345],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function isShouldNotNotAcceptInvalidLengths(): void
|
|
||||||
{
|
|
||||||
$this->expectException(ComponentException::class);
|
|
||||||
$this->expectExceptionMessage('10 cannot be less than 1 for validation');
|
|
||||||
|
|
||||||
new Length(10, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class LessThanTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new LessThan(10), 9],
|
[new LessThan(10), 9],
|
||||||
|
@ -40,7 +40,7 @@ final class LessThanTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new LessThan(10), 10],
|
[new LessThan(10), 10],
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class LowercaseTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Lowercase();
|
$rule = new Lowercase();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ final class LowercaseTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Lowercase();
|
$rule = new Lowercase();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class LuhnTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Luhn();
|
$rule = new Luhn();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ final class LuhnTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Luhn();
|
$rule = new Luhn();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ final class MacAddressTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new MacAddress();
|
$sut = new MacAddress();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ final class MacAddressTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new MacAddress();
|
$sut = new MacAddress();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ final class MaxAgeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new MaxAge(30, 'Y-m-d'), date('Y-m-d', strtotime('30 years ago'))],
|
[new MaxAge(30, 'Y-m-d'), date('Y-m-d', strtotime('30 years ago'))],
|
||||||
|
@ -44,7 +44,7 @@ final class MaxAgeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new MaxAge(30), new DateTime('30 years ago')],
|
[new MaxAge(30), new DateTime('30 years ago')],
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class MaxTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Max(10), 9],
|
[new Max(10), 9],
|
||||||
|
@ -46,7 +46,7 @@ final class MaxTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Max(10), 11],
|
[new Max(10), 11],
|
||||||
|
|
|
@ -59,7 +59,7 @@ final class MimetypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'image/png' => [new Mimetype('image/png'), 'tests/fixtures/valid-image.png'],
|
'image/png' => [new Mimetype('image/png'), 'tests/fixtures/valid-image.png'],
|
||||||
|
@ -74,7 +74,7 @@ final class MimetypeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'invalid file' => [new Mimetype('image/png'), 'tests/fixtures/invalid-image.png'],
|
'invalid file' => [new Mimetype('image/png'), 'tests/fixtures/invalid-image.png'],
|
||||||
|
|
|
@ -33,7 +33,7 @@ final class MinAgeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new MinAge(18, 'Y-m-d'), date('Y-m-d', strtotime('18 years ago'))],
|
[new MinAge(18, 'Y-m-d'), date('Y-m-d', strtotime('18 years ago'))],
|
||||||
|
@ -46,7 +46,7 @@ final class MinAgeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new MinAge(18), new DateTime('18 years ago')],
|
[new MinAge(18), new DateTime('18 years ago')],
|
||||||
|
|
|
@ -30,7 +30,7 @@ final class MinTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// From documentation
|
// From documentation
|
||||||
|
@ -61,7 +61,7 @@ final class MinTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// From documentation
|
// From documentation
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class MultipleTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Multiple(5), 20],
|
[new Multiple(5), 20],
|
||||||
|
@ -44,7 +44,7 @@ final class MultipleTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new Multiple(5), 11],
|
[new Multiple(5), 11],
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class NegativeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Negative();
|
$rule = new Negative();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ final class NegativeTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Negative();
|
$rule = new Negative();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class NfeAccessKeyTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$nfe = new NfeAccessKey();
|
$nfe = new NfeAccessKey();
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ final class NfeAccessKeyTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$nfe = new NfeAccessKey();
|
$nfe = new NfeAccessKey();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class NifTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Nif();
|
$rule = new Nif();
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ final class NifTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Nif();
|
$rule = new Nif();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class NipTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Nip();
|
$rule = new Nip();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ final class NipTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new Nip();
|
$rule = new Nip();
|
||||||
|
|
||||||
|
|
|
@ -31,63 +31,6 @@ final class NoTest extends RuleTestCase
|
||||||
*/
|
*/
|
||||||
private $locale;
|
private $locale;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForValidInput(): array
|
|
||||||
{
|
|
||||||
$sut = new No();
|
|
||||||
|
|
||||||
return [
|
|
||||||
[$sut, 'N'],
|
|
||||||
[$sut, 'Nay'],
|
|
||||||
[$sut, 'Nix'],
|
|
||||||
[$sut, 'No'],
|
|
||||||
[$sut, 'Nope'],
|
|
||||||
[$sut, 'Not'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function providerForInvalidInput(): array
|
|
||||||
{
|
|
||||||
$sut = new No();
|
|
||||||
|
|
||||||
return [
|
|
||||||
[$sut, 'Donnot'],
|
|
||||||
[$sut, 'Never'],
|
|
||||||
[$sut, 'Niet'],
|
|
||||||
[$sut, 'Noooooooo'],
|
|
||||||
[$sut, 'Não'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[][]
|
|
||||||
*/
|
|
||||||
public function providerForValidInputWithLocale(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'nl' => ['nl_NL.UTF-8', 'Nee'],
|
|
||||||
'pt' => ['pt_BR.UTF-8', 'Não'],
|
|
||||||
'ru' => ['ru_RU.UTF-8', 'нет'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string[][]
|
|
||||||
*/
|
|
||||||
public function providerForInvalidInputWithLocale(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'nl' => ['nl_NL.UTF-8', 'Ez'],
|
|
||||||
'pt' => ['pt_BR.UTF-8', 'нет'],
|
|
||||||
'ru' => ['pt_BR.UTF-8', 'Οχι'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*
|
*
|
||||||
|
@ -120,6 +63,63 @@ final class NoTest extends RuleTestCase
|
||||||
self::assertInvalidInput(new No(true), $input);
|
self::assertInvalidInput(new No(true), $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[][]
|
||||||
|
*/
|
||||||
|
public static function providerForValidInputWithLocale(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'nl' => ['nl_NL.UTF-8', 'Nee'],
|
||||||
|
'pt' => ['pt_BR.UTF-8', 'Não'],
|
||||||
|
'ru' => ['ru_RU.UTF-8', 'нет'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[][]
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidInputWithLocale(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'nl' => ['nl_NL.UTF-8', 'Ez'],
|
||||||
|
'pt' => ['pt_BR.UTF-8', 'нет'],
|
||||||
|
'ru' => ['pt_BR.UTF-8', 'Οχι'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForValidInput(): array
|
||||||
|
{
|
||||||
|
$sut = new No();
|
||||||
|
|
||||||
|
return [
|
||||||
|
[$sut, 'N'],
|
||||||
|
[$sut, 'Nay'],
|
||||||
|
[$sut, 'Nix'],
|
||||||
|
[$sut, 'No'],
|
||||||
|
[$sut, 'Nope'],
|
||||||
|
[$sut, 'Not'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public static function providerForInvalidInput(): array
|
||||||
|
{
|
||||||
|
$sut = new No();
|
||||||
|
|
||||||
|
return [
|
||||||
|
[$sut, 'Donnot'],
|
||||||
|
[$sut, 'Never'],
|
||||||
|
[$sut, 'Niet'],
|
||||||
|
[$sut, 'Noooooooo'],
|
||||||
|
[$sut, 'Não'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class NoWhitespaceTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NoWhitespace();
|
$rule = new NoWhitespace();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ final class NoWhitespaceTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NoWhitespace();
|
$rule = new NoWhitespace();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class NotBlankTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$object = new stdClass();
|
$object = new stdClass();
|
||||||
$object->foo = true;
|
$object->foo = true;
|
||||||
|
@ -45,7 +45,7 @@ final class NotBlankTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NotBlank();
|
$rule = new NotBlank();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class NotEmojiTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new NotEmoji();
|
$sut = new NotEmoji();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ final class NotEmojiTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$sut = new NotEmoji();
|
$sut = new NotEmoji();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class NotEmptyTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NotEmpty();
|
$rule = new NotEmpty();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ final class NotEmptyTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NotEmpty();
|
$rule = new NotEmpty();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class NotOptionalTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForValidInput(): array
|
public static function providerForValidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NotOptional();
|
$rule = new NotOptional();
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ final class NotOptionalTest extends RuleTestCase
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidInput(): array
|
public static function providerForInvalidInput(): array
|
||||||
{
|
{
|
||||||
$rule = new NotOptional();
|
$rule = new NotOptional();
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ final class NotTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForValidNot(): array
|
public static function providerForValidNot(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new IntVal(), ''],
|
[new IntVal(), ''],
|
||||||
|
@ -91,7 +91,7 @@ final class NotTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @return mixed[][]
|
* @return mixed[][]
|
||||||
*/
|
*/
|
||||||
public function providerForInvalidNot(): array
|
public static function providerForInvalidNot(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new IntVal(), 123],
|
[new IntVal(), 123],
|
||||||
|
@ -104,7 +104,7 @@ final class NotTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @return Validatable[][]
|
* @return Validatable[][]
|
||||||
*/
|
*/
|
||||||
public function providerForSetName(): array
|
public static function providerForSetName(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'non-allOf' => [new IntVal()],
|
'non-allOf' => [new IntVal()],
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue