mirror of
https://github.com/Respect/Validation.git
synced 2024-05-14 20:26:35 +02:00
Upgrade "phpunit/phpunit"
This commit also replaces PHPUnit annotations with attributes. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
9a19b235f8
commit
12c145756c
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
|||
.couscous/
|
||||
.iso-codes-cache/
|
||||
.phpcs.cache
|
||||
.phpunit.result.cache
|
||||
.phpunit.cache/
|
||||
composer.lock
|
||||
Makefile
|
||||
phpcs.xml
|
||||
|
|
|
@ -132,12 +132,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\HelloWorld
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(HelloWorld::class)]
|
||||
final class HelloWorldTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.3",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"phpunit/phpunit": "^10.5",
|
||||
"psr/http-message": "^1.0",
|
||||
"respect/coding-standard": "^4.0",
|
||||
"squizlabs/php_codesniffer": "^3.8"
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
verbose="true">
|
||||
cacheDirectory=".phpunit.cache"
|
||||
backupStaticProperties="false">
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory suffix="Test.php">tests/unit/</directory>
|
||||
|
@ -18,9 +15,9 @@
|
|||
<directory suffix=".phpt">tests/integration/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage processUncoveredFiles="true" ignoreDeprecatedCodeUnits="true">
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">library/</directory>
|
||||
<directory suffix=".php">library/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
</source>
|
||||
</phpunit>
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Test;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
use function implode;
|
||||
|
@ -17,9 +19,6 @@ use function realpath;
|
|||
use function Respect\Stringifier\stringify;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class RuleTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
|
@ -29,7 +28,7 @@ abstract class RuleTestCase extends TestCase
|
|||
* as the first element and an input in which the validation SHOULD pass.
|
||||
*
|
||||
* @api
|
||||
* @return mixed[][]
|
||||
* @return array<string|int, array{Validatable, mixed}>
|
||||
*/
|
||||
abstract public static function providerForValidInput(): array;
|
||||
|
||||
|
@ -40,23 +39,19 @@ abstract class RuleTestCase extends TestCase
|
|||
* as the first element and an input in which the validation SHOULD NOT pass.
|
||||
*
|
||||
* @api
|
||||
* @return mixed[][]
|
||||
* @return array<string|int, array{Validatable, mixed}>
|
||||
*/
|
||||
abstract public static function providerForInvalidInput(): array;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForValidInput
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForValidInput')]
|
||||
public function shouldValidateValidInput(Validatable $validator, mixed $input): void
|
||||
{
|
||||
self::assertValidInput($validator, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForInvalidInput
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForInvalidInput')]
|
||||
public function shouldValidateInvalidInput(Validatable $validator, mixed $input): void
|
||||
{
|
||||
self::assertInvalidInput($validator, $input);
|
||||
|
|
|
@ -10,6 +10,9 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
use DirectoryIterator;
|
||||
use PHPUnit\Framework\Attributes\CoversNothing;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use ReflectionClass;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
|
@ -17,15 +20,11 @@ use function class_exists;
|
|||
use function mb_substr;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
#[CoversNothing]
|
||||
final class CheckExceptionsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideListOfRuleNames
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('provideListOfRuleNames')]
|
||||
public function ruleHasAnExceptionWhichHasValidApi(string $ruleName): void
|
||||
{
|
||||
$exceptionClass = 'Respect\\Validation\\Exceptions\\' . $ruleName . 'Exception';
|
||||
|
|
|
@ -9,18 +9,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Message\Formatter;
|
||||
use Respect\Validation\Message\Stringifier\KeepOriginalStringName;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Exceptions\NestedValidationException
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(NestedValidationException::class)]
|
||||
final class NestedValidationExceptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function getChildrenShouldReturnExceptionAddedByAddRelated(): void
|
||||
{
|
||||
$composite = new AttributeException('input', 'id', [], new Formatter('strval', new KeepOriginalStringName()));
|
||||
|
@ -30,9 +30,7 @@ final class NestedValidationExceptionTest extends TestCase
|
|||
self::assertContainsOnly(IntValException::class, $composite->getChildren());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function addingTheSameInstanceShouldAddJustOneSingleReference(): void
|
||||
{
|
||||
$composite = new AttributeException('input', 'id', [], new Formatter('strval', new KeepOriginalStringName()));
|
||||
|
|
|
@ -9,21 +9,20 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Exceptions;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Message\Formatter;
|
||||
use Respect\Validation\Message\Stringifier\KeepOriginalStringName;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* @group core
|
||||
* @covers \Respect\Validation\Exceptions\ValidationException
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(ValidationException::class)]
|
||||
final class ValidationExceptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldImplementException(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', [], $this->createFormatter());
|
||||
|
@ -31,9 +30,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertInstanceOf(Exception::class, $sut);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldRetrieveId(): void
|
||||
{
|
||||
$id = 'my id';
|
||||
|
@ -42,9 +39,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertSame($id, $sut->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldRetrieveParams(): void
|
||||
{
|
||||
$params = ['foo' => true, 'bar' => 23];
|
||||
|
@ -54,9 +49,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertSame($params, $sut->getParams());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldRetrieveOneSingleParameter(): void
|
||||
{
|
||||
$name = 'any name';
|
||||
|
@ -67,9 +60,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertSame($value, $sut->getParam($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReturnNullWhenParameterCanNotBeFound(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', [], $this->createFormatter());
|
||||
|
@ -77,9 +68,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertNull($sut->getParam('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldHaveTemplateByDefault(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', [], $this->createFormatter());
|
||||
|
@ -87,9 +76,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertSame('"input" must be valid', $sut->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateMode(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', [], $this->createFormatter());
|
||||
|
@ -98,9 +85,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertSame('"input" must not be valid', $sut->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateTemplate(): void
|
||||
{
|
||||
$template = 'This is my new template';
|
||||
|
@ -111,9 +96,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertEquals($template, $sut->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldTellWhenHasAsCustomUpdateTemplate(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', [], $this->createFormatter());
|
||||
|
@ -125,9 +108,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertTrue($sut->hasCustomTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUseFormatter(): void
|
||||
{
|
||||
$template = ' This is my new template ';
|
||||
|
@ -139,9 +120,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertEquals($expected, $sut->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReplacePlaceholders(): void
|
||||
{
|
||||
$sut = new ValidationException('foo', 'id', ['bar' => 1, 'baz' => 2], $this->createFormatter());
|
||||
|
@ -153,9 +132,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldKeepPlaceholdersThatCanNotReplace(): void
|
||||
{
|
||||
$sut = new ValidationException('foo', 'id', ['foo' => 1], $this->createFormatter());
|
||||
|
@ -167,9 +144,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateParams(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', ['foo' => 1], $this->createFormatter());
|
||||
|
@ -179,9 +154,7 @@ final class ValidationExceptionTest extends TestCase
|
|||
self::assertEquals('2', $sut->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldConvertToString(): void
|
||||
{
|
||||
$sut = new ValidationException('input', 'id', [], $this->createFormatter());
|
||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Exceptions\InvalidClassException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
|
@ -22,17 +25,14 @@ use Respect\Validation\Test\TestCase;
|
|||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Factory
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(Factory::class)]
|
||||
final class FactoryTest extends TestCase
|
||||
{
|
||||
private const TEST_RULES_NAMESPACE = 'Respect\\Validation\\Test\\Rules';
|
||||
private const TEST_EXCEPTIONS_NAMESPACE = 'Respect\\Validation\\Test\\Exceptions';
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldCreateRuleByNameBasedOnNamespace(): void
|
||||
{
|
||||
$factory = (new Factory())
|
||||
|
@ -41,9 +41,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertInstanceOf(Valid::class, $factory->rule('valid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldLookUpToAllNamespacesUntilRuleIsFound(): void
|
||||
{
|
||||
$factory = (new Factory())
|
||||
|
@ -53,9 +51,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertInstanceOf(Valid::class, $factory->rule('valid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldDefineConstructorArgumentsWhenCreatingRule(): void
|
||||
{
|
||||
$constructorArguments = [true, false, true, false];
|
||||
|
@ -67,9 +63,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertSame($constructorArguments, $rule->validations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldThrowsAnExceptionWhenRuleIsInvalid(): void
|
||||
{
|
||||
$factory = (new Factory())->withRuleNamespace(self::TEST_RULES_NAMESPACE);
|
||||
|
@ -80,9 +74,7 @@ final class FactoryTest extends TestCase
|
|||
$factory->rule('invalid');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldThrowsAnExceptionWhenRuleIsNotInstantiable(): void
|
||||
{
|
||||
$factory = (new Factory())->withRuleNamespace(self::TEST_RULES_NAMESPACE);
|
||||
|
@ -93,9 +85,7 @@ final class FactoryTest extends TestCase
|
|||
$factory->rule('abstractClass');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldThrowsAnExceptionWhenRuleIsNotFound(): void
|
||||
{
|
||||
$factory = (new Factory())->withRuleNamespace(self::TEST_RULES_NAMESPACE);
|
||||
|
@ -106,9 +96,7 @@ final class FactoryTest extends TestCase
|
|||
$factory->rule('notFoundRule');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldCreateExceptionBasedOnRule(): void
|
||||
{
|
||||
$factory = (new Factory())->withExceptionNamespace(self::TEST_EXCEPTIONS_NAMESPACE);
|
||||
|
@ -119,9 +107,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertInstanceOf(StubException::class, $factory->exception($rule, $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldLookUpToAllNamespacesUntilExceptionIsCreated(): void
|
||||
{
|
||||
$factory = (new Factory())
|
||||
|
@ -134,9 +120,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertInstanceOf(StubException::class, $factory->exception($rule, $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldCreateValidationExceptionWhenExceptionIsNotFound(): void
|
||||
{
|
||||
$factory = new Factory();
|
||||
|
@ -146,9 +130,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertInstanceOf(ValidationException::class, $factory->exception($rule, $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldSetInputAsParameterOfCreatedException(): void
|
||||
{
|
||||
$factory = (new Factory())->withExceptionNamespace(self::TEST_EXCEPTIONS_NAMESPACE);
|
||||
|
@ -161,9 +143,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertSame($input, $exception->getParam('input'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldPassPropertiesToCreatedException(): void
|
||||
{
|
||||
$factory = (new Factory())->withExceptionNamespace(self::TEST_EXCEPTIONS_NAMESPACE);
|
||||
|
@ -177,9 +157,7 @@ final class FactoryTest extends TestCase
|
|||
self::assertSame($validations, $exception->getParam('validations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldSetTemplateWhenTemplateKeyIsDefined(): void
|
||||
{
|
||||
$factory = (new Factory())->withExceptionNamespace(self::TEST_EXCEPTIONS_NAMESPACE);
|
||||
|
@ -197,17 +175,13 @@ final class FactoryTest extends TestCase
|
|||
self::assertSame($extraParams['template'], $exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldAlwaysReturnTheSameDefaultInstance(): void
|
||||
{
|
||||
self::assertSame(Factory::getDefaultInstance(), Factory::getDefaultInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldBeAbleToOverwriteDefaultInstance(): void
|
||||
{
|
||||
$factory = new Factory();
|
||||
|
@ -221,9 +195,7 @@ final class FactoryTest extends TestCase
|
|||
Factory::setDefaultInstance($defaultInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldAutoResolveExceptionIfNamespacePatternMatchesAndExceptionClassFound(): void
|
||||
{
|
||||
$this->expectException(StubException::class);
|
||||
|
@ -232,9 +204,7 @@ final class FactoryTest extends TestCase
|
|||
$rule->assert('test');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldUseDefaultExceptionIfCustomExceptionNotFound(): void
|
||||
{
|
||||
$this->expectException(ValidationException::class);
|
||||
|
|
|
@ -9,29 +9,27 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Helpers;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group helper
|
||||
* @covers \Respect\Validation\Helpers\CanValidateDateTime
|
||||
*/
|
||||
#[Group('helper')]
|
||||
#[CoversClass(CanValidateDateTime::class)]
|
||||
final class CanValidateDateTimeTest extends TestCase
|
||||
{
|
||||
use CanValidateDateTime;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForValidDateTime
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForValidDateTime')]
|
||||
public function shouldFindWhenValueIsDateTime(string $format, string $value): void
|
||||
{
|
||||
self::assertTrue($this->isDateTime($format, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForInvalidDateTime
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForInvalidDateTime')]
|
||||
public function shouldFindWhenValueIsNotDateTime(string $format, string $value): void
|
||||
{
|
||||
self::assertFalse($this->isDateTime($format, $value));
|
||||
|
|
|
@ -9,31 +9,29 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Helpers;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\DataProvider\UndefinedProvider;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group helper
|
||||
* @covers \Respect\Validation\Helpers\CanValidateUndefined
|
||||
*/
|
||||
#[Group('helper')]
|
||||
#[CoversClass(CanValidateUndefined::class)]
|
||||
final class CanValidateUndefinedTest extends TestCase
|
||||
{
|
||||
use CanValidateUndefined;
|
||||
use UndefinedProvider;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForUndefined
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForUndefined')]
|
||||
public function shouldFindWhenValueIsUndefined(mixed $value): void
|
||||
{
|
||||
self::assertTrue($this->isUndefined($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForNotUndefined
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForNotUndefined')]
|
||||
public function shouldFindWhenValueIsNotUndefined(mixed $value): void
|
||||
{
|
||||
self::assertFalse($this->isUndefined($value));
|
||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\Exceptions\CompositeStubException;
|
||||
use Respect\Validation\Test\Rules\Stub;
|
||||
use Respect\Validation\Test\Stubs\CompositeSub;
|
||||
|
@ -16,15 +19,11 @@ use Respect\Validation\Test\TestCase;
|
|||
|
||||
use function current;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractComposite
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractComposite::class)]
|
||||
final class AbstractCompositeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateTheNameOfTheChildWhenUpdatingItsName(): void
|
||||
{
|
||||
$ruleName = 'something';
|
||||
|
@ -40,9 +39,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
self::assertSame($ruleName, $child->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateTheNameOfTheChildWhenAddingIt(): void
|
||||
{
|
||||
$ruleName = 'something';
|
||||
|
@ -59,9 +56,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
self::assertSame($ruleName, $rule->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldNotUpdateTheNameOfTheChildWhenUpdatingItsNameIfTheChildAlreadyHasSomeName(): void
|
||||
{
|
||||
$ruleName1 = 'something';
|
||||
|
@ -76,9 +71,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
self::assertSame($ruleName1, $rule->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itNotShouldUpdateTheNameOfTheChildWhenAddingItIfTheChildAlreadyHasSomeName(): void
|
||||
{
|
||||
$ruleName1 = 'something';
|
||||
|
@ -94,9 +87,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
self::assertSame($ruleName1, $rule->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReturnItsChildren(): void
|
||||
{
|
||||
$child1 = new Stub();
|
||||
|
@ -112,9 +103,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
self::assertSame($child3, $children[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldAssertWithAllChildrenAndNotThrowAnExceptionWhenThereAreNoIssues(): void
|
||||
{
|
||||
$input = 'something';
|
||||
|
@ -129,9 +118,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldAssertWithAllChildrenAndThrowAnExceptionWhenThereAreIssues(): void
|
||||
{
|
||||
$sut = new CompositeSub(new Stub(false), new Stub(false), new Stub(false));
|
||||
|
@ -143,9 +130,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateTheTemplateOfEveryChildrenWhenAsserting(): void
|
||||
{
|
||||
$template = 'This is my template';
|
||||
|
@ -166,9 +151,7 @@ final class AbstractCompositeTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldUpdateTheTemplateOfEveryTheChildrenOfSomeChildWhenAsserting(): void
|
||||
{
|
||||
$template = 'This is my template';
|
||||
|
|
|
@ -9,20 +9,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\Rules\Envelop;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
use function array_intersect_key;
|
||||
|
||||
/**
|
||||
* @test core
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(AbstractEnvelope::class)]
|
||||
final class AbstractEnvelopeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldValidateUsingTheInnerRule(): void
|
||||
{
|
||||
$rule = new Envelop(new AlwaysValid(), []);
|
||||
|
@ -30,9 +29,7 @@ final class AbstractEnvelopeTest extends TestCase
|
|||
self::assertTrue($rule->validate('something'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldInvalidateUsingTheInnerRule(): void
|
||||
{
|
||||
$rule = new Envelop(new AlwaysInvalid(), []);
|
||||
|
@ -40,9 +37,7 @@ final class AbstractEnvelopeTest extends TestCase
|
|||
self::assertFalse($rule->validate('something'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReportErrorUsingProperties(): void
|
||||
{
|
||||
$input = 'value';
|
||||
|
|
|
@ -9,21 +9,20 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Test\Rules\Stub;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
use function random_int;
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(AbstractRule::class)]
|
||||
final class AbstractRuleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::__invoke
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldValidateSomeValidInputUsingTheInvokeMagicMethod(): void
|
||||
{
|
||||
$sut = new Stub(true);
|
||||
|
@ -31,10 +30,7 @@ final class AbstractRuleTest extends TestCase
|
|||
self::assertTrue($sut('something'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::__invoke
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldValidateSomeInvalidInputUsingTheInvokeMagicMethod(): void
|
||||
{
|
||||
$sut = new Stub(false);
|
||||
|
@ -42,10 +38,7 @@ final class AbstractRuleTest extends TestCase
|
|||
self::assertFalse($sut('something'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::assert
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowAnExceptionOnAssertingSomeInvalidInput(): void
|
||||
{
|
||||
$input = 'something';
|
||||
|
@ -57,10 +50,7 @@ final class AbstractRuleTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::assert
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldNotThrowAnExceptionOnAssertingSomeValidInput(): void
|
||||
{
|
||||
$input = 'something';
|
||||
|
@ -72,10 +62,7 @@ final class AbstractRuleTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::check
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowAnExceptionOnCheckingSomeInvalidInput(): void
|
||||
{
|
||||
$input = 'something';
|
||||
|
@ -87,10 +74,7 @@ final class AbstractRuleTest extends TestCase
|
|||
$sut->check($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::check
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldNotThrowAnExceptionOnCheckingSomeValidInput(): void
|
||||
{
|
||||
$input = 'something';
|
||||
|
@ -102,10 +86,7 @@ final class AbstractRuleTest extends TestCase
|
|||
$sut->check($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::setTemplate
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReturnSelfWhenSettingSomeTemplate(): void
|
||||
{
|
||||
$sut = new Stub();
|
||||
|
@ -113,10 +94,7 @@ final class AbstractRuleTest extends TestCase
|
|||
self::assertSame($sut, $sut->setTemplate('whatever'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::setName
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReturnSelfWhenSettingSomeName(): void
|
||||
{
|
||||
$sut = new Stub();
|
||||
|
@ -124,10 +102,7 @@ final class AbstractRuleTest extends TestCase
|
|||
self::assertSame($sut, $sut->setName('whatever'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::getName
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldBeAbleToRetrieveItsName(): void
|
||||
{
|
||||
$name = 'something';
|
||||
|
@ -138,10 +113,7 @@ final class AbstractRuleTest extends TestCase
|
|||
self::assertSame($name, $sut->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Respect\Validation\Rules\AbstractRule::getName
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldReportErrorWithExtraParameters(): void
|
||||
{
|
||||
$extraParameterName = 'foo';
|
||||
|
|
|
@ -9,21 +9,21 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\DataProvider\UndefinedProvider;
|
||||
use Respect\Validation\Test\Rules\SearcherStub;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group core
|
||||
* @covers \Respect\Validation\Rules\AbstractSearcher
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(AbstractSearcher::class)]
|
||||
final class AbstractSearcherTest extends TestCase
|
||||
{
|
||||
use UndefinedProvider;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldValidateFromDataSource(): void
|
||||
{
|
||||
$input = 'BAZ';
|
||||
|
@ -33,9 +33,7 @@ final class AbstractSearcherTest extends TestCase
|
|||
self::assertTrue($rule->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldNotFindWhenNotIdentical(): void
|
||||
{
|
||||
$input = 2.0;
|
||||
|
@ -45,10 +43,8 @@ final class AbstractSearcherTest extends TestCase
|
|||
self::assertFalse($rule->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForUndefined
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForUndefined')]
|
||||
public function shouldValidateWhenValueIsUndefinedAndDataSourceIsEmpty(mixed $input): void
|
||||
{
|
||||
$rule = new SearcherStub(static fn() => []);
|
||||
|
@ -56,10 +52,8 @@ final class AbstractSearcherTest extends TestCase
|
|||
self::assertTrue($rule->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForNotUndefined
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForNotUndefined')]
|
||||
public function shouldNotValidateWhenValueIsNotUndefinedAndDataSourceNotEmpty(mixed $input): void
|
||||
{
|
||||
$rule = new SearcherStub(static fn() => []);
|
||||
|
|
|
@ -9,20 +9,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Test\Rules\Stub;
|
||||
use Respect\Validation\Test\Rules\WrapperStub;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @test core
|
||||
* @covers \Respect\Validation\Rules\AbstractWrapper
|
||||
*/
|
||||
#[Group('core')]
|
||||
#[CoversClass(AbstractWrapper::class)]
|
||||
final class AbstractWrapperTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldUseWrappedToValidate(): void
|
||||
{
|
||||
$sut = new WrapperStub(new Stub(true));
|
||||
|
@ -30,9 +29,7 @@ final class AbstractWrapperTest extends TestCase
|
|||
self::assertTrue($sut->validate('Whatever'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldUseWrappedToAssert(): void
|
||||
{
|
||||
$sut = new WrapperStub(new Stub(false));
|
||||
|
@ -40,9 +37,7 @@ final class AbstractWrapperTest extends TestCase
|
|||
$sut->assert('Whatever');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldUseWrappedToCheck(): void
|
||||
{
|
||||
$sut = new WrapperStub(new Stub(false));
|
||||
|
@ -50,9 +45,7 @@ final class AbstractWrapperTest extends TestCase
|
|||
$sut->check('Whatever');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldPassNameOnToWrapped(): void
|
||||
{
|
||||
$name = 'Whatever';
|
||||
|
|
|
@ -9,22 +9,22 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Exceptions\CallbackException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Exceptions\AllOfException
|
||||
* @covers \Respect\Validation\Rules\AllOf
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AllOfException::class)]
|
||||
#[CoversClass(AllOf::class)]
|
||||
final class AllOfTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function validationShouldWorkIfAllRulesReturnTrue(): void
|
||||
{
|
||||
$valid1 = new Callback(static function () {
|
||||
|
@ -45,10 +45,8 @@ final class AllOfTest extends TestCase
|
|||
$o->assert('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerStaticDummyRules
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerStaticDummyRules')]
|
||||
public function validationAssertShouldFailIfAnyRuleFailsAndReturnAllExceptionsFailed(
|
||||
Validatable $rule1,
|
||||
Validatable $rule2,
|
||||
|
@ -61,10 +59,8 @@ final class AllOfTest extends TestCase
|
|||
$o->assert('any');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerStaticDummyRules
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerStaticDummyRules')]
|
||||
public function validationCheckShouldFailIfAnyRuleFailsAndThrowTheFirstExceptionOnly(
|
||||
Validatable $rule1,
|
||||
Validatable $rule2,
|
||||
|
@ -77,11 +73,8 @@ final class AllOfTest extends TestCase
|
|||
$o->check('any');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerStaticDummyRules
|
||||
* @expectedException \Respect\Validation\Exceptions\
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerStaticDummyRules')]
|
||||
public function validationCheckShouldFailOnEmptyInput(
|
||||
Validatable $rule1,
|
||||
Validatable $rule2,
|
||||
|
@ -93,10 +86,8 @@ final class AllOfTest extends TestCase
|
|||
$o->check('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerStaticDummyRules
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerStaticDummyRules')]
|
||||
public function validationShouldFailIfAnyRuleFails(
|
||||
Validatable $rule1,
|
||||
Validatable $rule2,
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Alnum
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractFilterRule::class)]
|
||||
#[CoversClass(Alnum::class)]
|
||||
final class AlnumTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Alpha
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractFilterRule::class)]
|
||||
#[CoversClass(Alpha::class)]
|
||||
final class AlphaTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,18 +9,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AlwaysInvalid
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AlwaysInvalid::class)]
|
||||
final class AlwaysInvalidTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForInvalidInput
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForInvalidInput')]
|
||||
public function itShouldAlwaysBeInvalid(mixed $input): void
|
||||
{
|
||||
$rule = new AlwaysInvalid();
|
||||
|
|
|
@ -9,18 +9,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AlwaysValid
|
||||
*/
|
||||
#[Group(' rule')]
|
||||
#[CoversClass(AlwaysValid::class)]
|
||||
final class AlwaysValidTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForValidInput
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForValidInput')]
|
||||
public function itAlwaysBeValid(mixed $input): void
|
||||
{
|
||||
$rule = new AlwaysValid();
|
||||
|
|
|
@ -9,20 +9,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\AnyOfException;
|
||||
use Respect\Validation\Exceptions\XdigitException;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Exceptions\AnyOfException
|
||||
* @covers \Respect\Validation\Rules\AnyOf
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AnyOfException::class)]
|
||||
#[CoversClass(AnyOf::class)]
|
||||
final class AnyOfTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function valid(): void
|
||||
{
|
||||
$valid1 = new Callback(static function () {
|
||||
|
@ -40,9 +39,7 @@ final class AnyOfTest extends TestCase
|
|||
$o->check('any');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function invalid(): void
|
||||
{
|
||||
$valid1 = new Callback(static function () {
|
||||
|
@ -61,9 +58,7 @@ final class AnyOfTest extends TestCase
|
|||
$o->assert('any');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function invalidCheck(): void
|
||||
{
|
||||
$o = new AnyOf(new Xdigit(), new Alnum());
|
||||
|
|
|
@ -11,12 +11,12 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use ArrayIterator;
|
||||
use ArrayObject;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\ArrayType
|
||||
*/
|
||||
#[Group(' rule')]
|
||||
#[CoversClass(ArrayType::class)]
|
||||
final class ArrayTypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,14 +10,14 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use ArrayObject;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SimpleXMLElement;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\ArrayVal
|
||||
*/
|
||||
#[Group(' rule')]
|
||||
#[CoversClass(ArrayVal::class)]
|
||||
final class ArrayValTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,15 +9,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\WithProperties;
|
||||
use Respect\Validation\Test\Stubs\WithUninitialized;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractRelated
|
||||
* @covers \Respect\Validation\Rules\Attribute
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractRelated::class)]
|
||||
#[CoversClass(Attribute::class)]
|
||||
final class AttributeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use function implode;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Base64
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Base64::class)]
|
||||
final class Base64Test extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Base
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Base::class)]
|
||||
final class BaseTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,20 +10,19 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\CountableStub;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\Between
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractEnvelope::class)]
|
||||
#[CoversClass(Between::class)]
|
||||
final class BetweenTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function minimumValueShouldNotBeGreaterThanMaximumValue(): void
|
||||
{
|
||||
$this->expectExceptionObject(new ComponentException('Minimum cannot be less than or equals to maximum'));
|
||||
|
@ -31,9 +30,7 @@ final class BetweenTest extends RuleTestCase
|
|||
new Between(10, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function minimumValueShouldNotBeEqualsToMaximumValue(): void
|
||||
{
|
||||
$this->expectExceptionObject(new ComponentException('Minimum cannot be less than or equals to maximum'));
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\BoolType
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(BoolType::class)]
|
||||
final class BoolTypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\BoolVal
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(BoolVal::class)]
|
||||
final class BoolValTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Bsn
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Bsn::class)]
|
||||
final class BsnTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,9 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\AlwaysInvalidException;
|
||||
use Respect\Validation\Exceptions\CallException;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
|
@ -20,17 +23,13 @@ use function restore_error_handler;
|
|||
use function set_error_handler;
|
||||
use function trigger_error;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Call
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Call::class)]
|
||||
final class CallTest extends TestCase
|
||||
{
|
||||
private readonly ErrorException $errorException;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function assertShouldExecuteCallable(): void
|
||||
{
|
||||
$input = ' input ';
|
||||
|
@ -46,9 +45,7 @@ final class CallTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function assertShouldThrowCallExceptionWhenPhpTriggersAnError(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -65,9 +62,7 @@ final class CallTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function assertShouldRestorePreviousPhpErrorHandler(): void
|
||||
{
|
||||
$callable = 'trim';
|
||||
|
@ -85,9 +80,7 @@ final class CallTest extends TestCase
|
|||
trigger_error('Forcing PHP to trigger an error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function assertShouldThrowCallExceptionWhenCallableThrowsAnException(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -106,9 +99,7 @@ final class CallTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function assertShouldThrowExceptionOfTheDefinedRule(): void
|
||||
{
|
||||
$input = 'something';
|
||||
|
@ -122,9 +113,7 @@ final class CallTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function checkShouldExecuteCallable(): void
|
||||
{
|
||||
$input = ' input ';
|
||||
|
@ -140,9 +129,7 @@ final class CallTest extends TestCase
|
|||
$sut->check($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function checkShouldThrowCallExceptionWhenPhpTriggersAnError(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -159,9 +146,7 @@ final class CallTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function checkShouldRestorePreviousPhpErrorHandler(): void
|
||||
{
|
||||
$callable = 'trim';
|
||||
|
@ -179,9 +164,7 @@ final class CallTest extends TestCase
|
|||
trigger_error('Forcing PHP to trigger an error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function checkShouldThrowCallExceptionWhenCallableThrowsAnException(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -200,9 +183,7 @@ final class CallTest extends TestCase
|
|||
$sut->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function checkShouldThrowExceptionOfTheDefinedRule(): void
|
||||
{
|
||||
$rule = new AlwaysInvalid();
|
||||
|
@ -213,9 +194,7 @@ final class CallTest extends TestCase
|
|||
$sut->check('something');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function validateShouldExecuteCallable(): void
|
||||
{
|
||||
$input = ' input ';
|
||||
|
@ -232,9 +211,7 @@ final class CallTest extends TestCase
|
|||
self::assertTrue($sut->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function validateShouldReturnFalseWhenPhpTriggersAnError(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -250,9 +227,7 @@ final class CallTest extends TestCase
|
|||
self::assertFalse($sut->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function validateShouldReturnFalseWhenDefinedRuleFails(): void
|
||||
{
|
||||
$sut = new Call('trim', new AlwaysInvalid());
|
||||
|
@ -260,9 +235,7 @@ final class CallTest extends TestCase
|
|||
self::assertFalse($sut->validate('something'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function validateShouldRestorePreviousPhpErrorHandler(): void
|
||||
{
|
||||
$callable = 'trim';
|
||||
|
|
|
@ -9,16 +9,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\WithMethods;
|
||||
use stdClass;
|
||||
|
||||
use const INF;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\CallableType
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(CallableType::class)]
|
||||
final class CallableTypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Callback
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Callback::class)]
|
||||
final class CallbackTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,20 +9,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use function mb_convert_encoding;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Charset
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Charset::class)]
|
||||
final class CharsetTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowsExceptionWhenCharsetIsNotValid(): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Cnh
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Cnh::class)]
|
||||
final class CnhTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Cnpj
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Cnpj::class)]
|
||||
final class CnpjTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Consonant
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractFilterRule::class)]
|
||||
#[CoversClass(Consonant::class)]
|
||||
final class ConsonantTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\ContainsAny
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(ContainsAny::class)]
|
||||
final class ContainsAnyTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Contains
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Contains::class)]
|
||||
final class ContainsTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Control
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractFilterRule::class)]
|
||||
#[CoversClass(Control::class)]
|
||||
final class ControlTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -11,15 +11,15 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use ArrayIterator;
|
||||
use ArrayObject;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Countable
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Countable::class)]
|
||||
final class CountableTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,18 +9,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\CountryCode
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(CountryCode::class)]
|
||||
final class CountryCodeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowsExceptionWhenInvalidFormat(): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Cpf
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Cpf::class)]
|
||||
final class CpfTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,18 +9,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\CreditCard
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(CreditCard::class)]
|
||||
final class CreditCardTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowExceptionWhenCreditCardBrandIsNotValid(): void
|
||||
{
|
||||
$message = '"RespectCard" is not a valid credit card brand';
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\CurrencyCode
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(CurrencyCode::class)]
|
||||
final class CurrencyCodeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -11,19 +11,19 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Date
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Date::class)]
|
||||
final class DateTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider validFormatsProvider
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('validFormatsProvider')]
|
||||
public function shouldThrowAnExceptionWhenFormatIsNotValid(string $format): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
@ -31,9 +31,7 @@ final class DateTest extends RuleTestCase
|
|||
new Date($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldPassFormatToParameterToException(): void
|
||||
{
|
||||
$format = 'F jS, Y';
|
||||
|
|
|
@ -11,20 +11,20 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use DateTime as DateTimeMutable;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use function date_default_timezone_get;
|
||||
use function date_default_timezone_set;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\DateTime
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(DateTime::class)]
|
||||
final class DateTimeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldPassFormatToParameterToException(): void
|
||||
{
|
||||
$format = 'F jS, Y';
|
||||
|
@ -34,10 +34,8 @@ final class DateTimeTest extends RuleTestCase
|
|||
self::assertSame($format, $exception->getParam('format'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForDateTimeWithTimezone
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForDateTimeWithTimezone')]
|
||||
public function shouldValidateNoMatterTimezone(string $format, string $input, string $timezone): void
|
||||
{
|
||||
$currentTimezone = date_default_timezone_get();
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
|
@ -17,10 +19,8 @@ use function sqrt;
|
|||
|
||||
use const NAN;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Decimal
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Decimal::class)]
|
||||
final class DecimalTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Digit
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractFilterRule::class)]
|
||||
#[CoversClass(Digit::class)]
|
||||
final class DigitTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use SplFileObject;
|
||||
|
@ -16,10 +18,8 @@ use stdClass;
|
|||
|
||||
use function dir;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Directory
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Directory::class)]
|
||||
final class DirectoryTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\ToStringStub;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Domain
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Domain::class)]
|
||||
final class DomainTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Validatable;
|
||||
|
@ -18,45 +21,35 @@ use Traversable;
|
|||
|
||||
use function range;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Each
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Each::class)]
|
||||
final class EachTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldAssertEachValue(): void
|
||||
{
|
||||
$validatable = $this->createMock(Validatable::class);
|
||||
$validatable
|
||||
->expects(self::exactly(3))
|
||||
->method('assert')
|
||||
->will($this->onConsecutiveCalls([1], [2], [3]));
|
||||
->method('assert');
|
||||
|
||||
$rule = new Each($validatable);
|
||||
$rule->assert(range(1, 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldCheckEachValue(): void
|
||||
{
|
||||
$validatable = $this->createMock(Validatable::class);
|
||||
$validatable
|
||||
->expects(self::exactly(3))
|
||||
->method('check')
|
||||
->will($this->onConsecutiveCalls([1], [2], [3]));
|
||||
->method('check');
|
||||
|
||||
$rule = new Each($validatable);
|
||||
$rule->check(range(1, 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldNotOverrideMessages(): void
|
||||
{
|
||||
$rule = new Each(new StringType());
|
||||
|
|
|
@ -11,20 +11,19 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use function tmpfile;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Email
|
||||
*/
|
||||
#[Group(' rule')]
|
||||
#[CoversClass(Email::class)]
|
||||
final class EmailTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldUseEmailValidatorToValidate(): void
|
||||
{
|
||||
$input = 'example@example.com';
|
||||
|
@ -36,7 +35,7 @@ final class EmailTest extends RuleTestCase
|
|||
->expects(self::once())
|
||||
->method('isValid')
|
||||
->with($input, self::isInstanceOf(RFCValidation::class))
|
||||
->will(self::returnValue(true));
|
||||
->willReturn(true);
|
||||
|
||||
$sut = new Email($emailValidator);
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\EndsWith
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(EndsWith::class)]
|
||||
final class EndsWithTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,18 +9,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Equals
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Equals::class)]
|
||||
final class EqualsTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldPassCompareToParameterToException(): void
|
||||
{
|
||||
$compareTo = new stdClass();
|
||||
|
|
|
@ -10,12 +10,12 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use ArrayObject;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Equivalent
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Equivalent::class)]
|
||||
final class EquivalentTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use const INF;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Even
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Even::class)]
|
||||
final class EvenTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use SplFileObject;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Executable
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Executable::class)]
|
||||
final class ExecutableTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use SplFileObject;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Exists
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Exists::class)]
|
||||
final class ExistsTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Extension
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Extension::class)]
|
||||
final class ExtensionTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,8 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
|
@ -19,10 +21,8 @@ use function uniqid;
|
|||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Factor
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Factor::class)]
|
||||
final class FactorTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
|
@ -16,10 +18,8 @@ use function random_int;
|
|||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\FalseVal
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(FalseVal::class)]
|
||||
final class FalseValTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Fibonacci
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Fibonacci::class)]
|
||||
final class FibonacciTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use SplFileObject;
|
||||
|
@ -16,10 +18,8 @@ use stdClass;
|
|||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\File
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(File::class)]
|
||||
final class FileTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
|
@ -22,16 +25,12 @@ use const FILTER_VALIDATE_FLOAT;
|
|||
use const FILTER_VALIDATE_INT;
|
||||
use const FILTER_VALIDATE_URL;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\FilterVar
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractEnvelope::class)]
|
||||
#[CoversClass(FilterVar::class)]
|
||||
final class FilterVarTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowsExceptionWhenFilterIsNotValid(): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
|
@ -17,10 +19,8 @@ use function acos;
|
|||
use const INF;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Finite
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Finite::class)]
|
||||
final class FiniteTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\FloatType
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(FloatType::class)]
|
||||
final class FloatTypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\FloatVal
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(FloatVal::class)]
|
||||
final class FloatValTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractFilterRule
|
||||
* @covers \Respect\Validation\Rules\Graph
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractFilterRule::class)]
|
||||
#[CoversClass(Graph::class)]
|
||||
final class GraphTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\CountableStub;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractComparison
|
||||
* @covers \Respect\Validation\Rules\GreaterThan
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractComparison::class)]
|
||||
#[CoversClass(GreaterThan::class)]
|
||||
final class GreaterThanTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\HexRgbColor
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(HexRgbColor::class)]
|
||||
final class HexRgbColorTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,15 +9,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use function extension_loaded;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Iban
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Iban::class)]
|
||||
final class IbanTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,18 +9,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Identical
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Identical::class)]
|
||||
final class IdenticalTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldPassCompareToParameterToException(): void
|
||||
{
|
||||
$compareTo = new stdClass();
|
||||
|
|
|
@ -10,19 +10,18 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use finfo;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use SplFileObject;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Image
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Image::class)]
|
||||
final class ImageTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldValidateWithDefinedInstanceOfFileInfo(): void
|
||||
{
|
||||
$input = self::fixture('valid-image.gif');
|
||||
|
@ -32,7 +31,7 @@ final class ImageTest extends RuleTestCase
|
|||
->expects(self::once())
|
||||
->method('file')
|
||||
->with($input)
|
||||
->will(self::returnValue('image/gif'));
|
||||
->willReturn('image/gif');
|
||||
|
||||
$rule = new Image($finfo);
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Imei
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Imei::class)]
|
||||
final class ImeiTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\In
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(In::class)]
|
||||
final class InTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,16 +9,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use const INF;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Infinite
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Infinite::class)]
|
||||
final class InfiniteTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -12,15 +12,15 @@ namespace Respect\Validation\Rules;
|
|||
use ArrayIterator;
|
||||
use ArrayObject;
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use stdClass;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Instance
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Instance::class)]
|
||||
final class InstanceTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\IntType
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(IntType::class)]
|
||||
final class IntTypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,15 +9,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\IntVal
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(IntVal::class)]
|
||||
final class IntValTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
|
@ -17,17 +21,12 @@ use function extension_loaded;
|
|||
use const FILTER_FLAG_IPV6;
|
||||
use const FILTER_FLAG_NO_PRIV_RANGE;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Ip
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Ip::class)]
|
||||
final class IpTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForInvalidRanges
|
||||
* @throws ComponentException
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForInvalidRanges')]
|
||||
public function invalidRangeShouldRaiseException(string $range): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Isbn
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Isbn::class)]
|
||||
final class IsbnTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,13 +10,13 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use ArrayIterator;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\IterableType
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(IterableType::class)]
|
||||
final class IterableTypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Json
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Json::class)]
|
||||
final class JsonTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,21 +10,21 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use ArrayObject;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\KeyNestedException;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
use Respect\Validation\Validatable;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractRelated
|
||||
* @covers \Respect\Validation\Rules\KeyNested
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractRelated::class)]
|
||||
#[CoversClass(KeyNested::class)]
|
||||
final class KeyNestedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithPresentKeysWillReturnTrueForFullPathValidator(): void
|
||||
{
|
||||
$array = [
|
||||
|
@ -43,9 +43,7 @@ final class KeyNestedTest extends TestCase
|
|||
self::assertTrue($rule->validate($array));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithNumericKeysWillReturnTrueForFullPathValidator(): void
|
||||
{
|
||||
$array = [
|
||||
|
@ -62,9 +60,7 @@ final class KeyNestedTest extends TestCase
|
|||
$rule->check($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithPresentKeysWillReturnTrueForHalfPathValidator(): void
|
||||
{
|
||||
$array = [
|
||||
|
@ -83,9 +79,7 @@ final class KeyNestedTest extends TestCase
|
|||
self::assertTrue($rule->validate($array));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function objectWithPresentPropertiesWillReturnTrueForDirtyPathValidator(): void
|
||||
{
|
||||
$object = (object) [
|
||||
|
@ -104,9 +98,7 @@ final class KeyNestedTest extends TestCase
|
|||
self::assertTrue($rule->validate($object));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function emptyInputMustReturnFalse(): void
|
||||
{
|
||||
$rule = new KeyNested('bar.foo.baz');
|
||||
|
@ -114,9 +106,7 @@ final class KeyNestedTest extends TestCase
|
|||
self::assertFalse($rule->validate(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function emptyInputMustNotAssert(): void
|
||||
{
|
||||
$rule = new KeyNested('bar.foo.baz');
|
||||
|
@ -124,9 +114,7 @@ final class KeyNestedTest extends TestCase
|
|||
$rule->assert('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function emptyInputMustNotCheck(): void
|
||||
{
|
||||
$rule = new KeyNested('bar.foo.baz');
|
||||
|
@ -134,9 +122,7 @@ final class KeyNestedTest extends TestCase
|
|||
$rule->check('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithEmptyKeyShouldReturnTrue(): void
|
||||
{
|
||||
$rule = new KeyNested('emptyKey');
|
||||
|
@ -145,9 +131,7 @@ final class KeyNestedTest extends TestCase
|
|||
self::assertTrue($rule->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithAbsentKeyShouldThrowNestedKeyException(): void
|
||||
{
|
||||
$validator = new KeyNested('bar.bar');
|
||||
|
@ -160,9 +144,7 @@ final class KeyNestedTest extends TestCase
|
|||
$validator->assert($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notArrayShouldThrowKeyException(): void
|
||||
{
|
||||
$validator = new KeyNested('baz.bar');
|
||||
|
@ -171,10 +153,8 @@ final class KeyNestedTest extends TestCase
|
|||
$validator->assert($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DoesNotPerformAssertions]
|
||||
public function extraValidatorShouldValidateKey(): void
|
||||
{
|
||||
$subValidator = new Length(3, 7);
|
||||
|
@ -189,9 +169,7 @@ final class KeyNestedTest extends TestCase
|
|||
$validator->assert($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notMandatoryExtraValidatorShouldPassWithAbsentKey(): void
|
||||
{
|
||||
$subValidator = new Length(1, 3);
|
||||
|
@ -200,9 +178,7 @@ final class KeyNestedTest extends TestCase
|
|||
self::assertTrue($validator->validate($object));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayAccessWithPresentKeysWillReturnTrue(): void
|
||||
{
|
||||
$arrayAccess = new ArrayObject([
|
||||
|
|
|
@ -9,20 +9,20 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Exceptions\KeySetException;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\KeySet
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(KeySet::class)]
|
||||
final class KeySetTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldNotAcceptAllOfWithMoreThanOneKeyRule(): void
|
||||
{
|
||||
$key1 = new Key('foo', new AlwaysValid(), false);
|
||||
|
@ -35,9 +35,7 @@ final class KeySetTest extends TestCase
|
|||
new KeySet($allOf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldNotAcceptAllOfWithNonKeyRule(): void
|
||||
{
|
||||
$alwaysValid = new AlwaysValid();
|
||||
|
@ -49,9 +47,7 @@ final class KeySetTest extends TestCase
|
|||
new KeySet($allOf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldNotAcceptNonKeyRule(): void
|
||||
{
|
||||
$alwaysValid = new AlwaysValid();
|
||||
|
@ -62,9 +58,7 @@ final class KeySetTest extends TestCase
|
|||
new KeySet($alwaysValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldValidateKeysWhenThereAreMissingRequiredKeys(): void
|
||||
{
|
||||
$input = [
|
||||
|
@ -79,9 +73,7 @@ final class KeySetTest extends TestCase
|
|||
self::assertFalse($keySet->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldValidateKeysWhenThereAreMissingNonRequiredKeys(): void
|
||||
{
|
||||
$input = [
|
||||
|
@ -96,9 +88,7 @@ final class KeySetTest extends TestCase
|
|||
self::assertTrue($keySet->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldValidateKeysWhenThereAreMoreKeys(): void
|
||||
{
|
||||
$input = [
|
||||
|
@ -115,9 +105,7 @@ final class KeySetTest extends TestCase
|
|||
self::assertFalse($keySet->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldValidateKeysWhenEmpty(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -130,9 +118,7 @@ final class KeySetTest extends TestCase
|
|||
self::assertFalse($keySet->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldCheckKeys(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -148,9 +134,7 @@ final class KeySetTest extends TestCase
|
|||
$keySet->check($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldAssertKeys(): void
|
||||
{
|
||||
$input = [];
|
||||
|
@ -166,9 +150,7 @@ final class KeySetTest extends TestCase
|
|||
$keySet->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldWarnOfExtraKeysWithMessage(): void
|
||||
{
|
||||
$input = ['foo' => 123, 'bar' => 456];
|
||||
|
@ -183,9 +165,7 @@ final class KeySetTest extends TestCase
|
|||
$keySet->assert($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function cannotBeNegated(): void
|
||||
{
|
||||
$key1 = new Key('foo', new AlwaysValid(), true);
|
||||
|
@ -196,10 +176,8 @@ final class KeySetTest extends TestCase
|
|||
new Not(new KeySet($key1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider providerForInvalidArguments
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('providerForInvalidArguments')]
|
||||
public function shouldThrowExceptionInCaseArgumentIsAnythingOtherThanArray(mixed $input): void
|
||||
{
|
||||
$keySet = new KeySet(new Key('name'));
|
||||
|
|
|
@ -9,21 +9,21 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Exceptions\KeyException;
|
||||
use Respect\Validation\Test\TestCase;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractRelated
|
||||
* @covers \Respect\Validation\Rules\Key
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractRelated::class)]
|
||||
#[CoversClass(Key::class)]
|
||||
final class KeyTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithPresentKeyShouldReturnTrue(): void
|
||||
{
|
||||
$validator = new Key('bar');
|
||||
|
@ -32,9 +32,7 @@ final class KeyTest extends TestCase
|
|||
self::assertTrue($validator->validate($someArray));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithNumericKeyShouldReturnTrue(): void
|
||||
{
|
||||
$validator = new Key(0);
|
||||
|
@ -43,9 +41,7 @@ final class KeyTest extends TestCase
|
|||
self::assertTrue($validator->validate($someArray));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function emptyInputMustReturnFalse(): void
|
||||
{
|
||||
$validator = new Key('someEmptyKey');
|
||||
|
@ -54,9 +50,7 @@ final class KeyTest extends TestCase
|
|||
self::assertFalse($validator->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function emptyInputMustNotAssert(): void
|
||||
{
|
||||
$validator = new Key('someEmptyKey');
|
||||
|
@ -66,9 +60,7 @@ final class KeyTest extends TestCase
|
|||
$validator->assert('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function emptyInputMustNotCheck(): void
|
||||
{
|
||||
$validator = new Key('someEmptyKey');
|
||||
|
@ -78,9 +70,7 @@ final class KeyTest extends TestCase
|
|||
$validator->check('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithEmptyKeyShouldReturnTrue(): void
|
||||
{
|
||||
$validator = new Key('someEmptyKey');
|
||||
|
@ -90,9 +80,7 @@ final class KeyTest extends TestCase
|
|||
self::assertTrue($validator->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function shouldHaveTheSameReturnValueForAllValidators(): void
|
||||
{
|
||||
$rule = new Key('key', new NotEmpty());
|
||||
|
@ -113,9 +101,7 @@ final class KeyTest extends TestCase
|
|||
self::assertFalse($rule->validate($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function arrayWithAbsentKeyShouldThrowKeyException(): void
|
||||
{
|
||||
$validator = new Key('bar');
|
||||
|
@ -127,9 +113,7 @@ final class KeyTest extends TestCase
|
|||
$validator->assert($someArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notArrayShouldThrowKeyException(): void
|
||||
{
|
||||
$validator = new Key('bar');
|
||||
|
@ -140,9 +124,7 @@ final class KeyTest extends TestCase
|
|||
$validator->assert($someArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function invalidConstructorParametersShouldThrowComponentExceptionUponInstantiation(): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
@ -150,10 +132,8 @@ final class KeyTest extends TestCase
|
|||
new Key(['invalid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
#[DoesNotPerformAssertions]
|
||||
public function extraValidatorShouldValidateKey(): void
|
||||
{
|
||||
$subValidator = new Length(1, 3);
|
||||
|
@ -163,9 +143,7 @@ final class KeyTest extends TestCase
|
|||
$validator->assert($someArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function notMandatoryExtraValidatorShouldPassWithAbsentKey(): void
|
||||
{
|
||||
$subValidator = new Length(1, 3);
|
||||
|
|
|
@ -9,12 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\KeyValue
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(KeyValue::class)]
|
||||
final class KeyValueTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,19 +9,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractEnvelope
|
||||
* @covers \Respect\Validation\Rules\LanguageCode
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractEnvelope::class)]
|
||||
#[CoversClass(LanguageCode::class)]
|
||||
final class LanguageCodeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldThrowAnExceptionWhenSetIsInvalid(): void
|
||||
{
|
||||
$this->expectExceptionObject(new ComponentException('"foo" is not a valid language set for ISO 639'));
|
||||
|
|
|
@ -10,12 +10,12 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\LeapDate
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(LeapDate::class)]
|
||||
final class LeapDateTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,12 +10,12 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\LeapYear
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(LeapYear::class)]
|
||||
final class LeapYearTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\CountableStub;
|
||||
|
@ -16,15 +19,11 @@ use Respect\Validation\Test\Stubs\CountableStub;
|
|||
use function range;
|
||||
use function tmpfile;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Length
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Length::class)]
|
||||
final class LengthTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function isShouldNotNotAcceptInvalidLengths(): void
|
||||
{
|
||||
$this->expectException(ComponentException::class);
|
||||
|
|
|
@ -9,14 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\CountableStub;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractComparison
|
||||
* @covers \Respect\Validation\Rules\LessThan
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractComparison::class)]
|
||||
#[CoversClass(LessThan::class)]
|
||||
final class LessThanTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Lowercase
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Lowercase::class)]
|
||||
final class LowercaseTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Luhn
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Luhn::class)]
|
||||
final class LuhnTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
|
||||
use function random_int;
|
||||
|
@ -16,10 +18,8 @@ use function tmpfile;
|
|||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\MacAddress
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(MacAddress::class)]
|
||||
final class MacAddressTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -11,17 +11,17 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use stdClass;
|
||||
|
||||
use function date;
|
||||
use function strtotime;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractAge
|
||||
* @covers \Respect\Validation\Rules\MaxAge
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractAge::class)]
|
||||
#[CoversClass(MaxAge::class)]
|
||||
final class MaxAgeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -11,14 +11,14 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\CountableStub;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\AbstractComparison
|
||||
* @covers \Respect\Validation\Rules\Max
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(AbstractComparison::class)]
|
||||
#[CoversClass(Max::class)]
|
||||
final class MaxTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,9 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use finfo;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use SplFileInfo;
|
||||
use SplFileObject;
|
||||
|
@ -20,15 +23,11 @@ use function tmpfile;
|
|||
use const FILEINFO_MIME_TYPE;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* @group rule
|
||||
* @covers \Respect\Validation\Rules\Mimetype
|
||||
*/
|
||||
#[Group('rule')]
|
||||
#[CoversClass(Mimetype::class)]
|
||||
final class MimetypeTest extends RuleTestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function itShouldValidateWithDefinedFinfoInstance(): void
|
||||
{
|
||||
$mimetype = 'application/octet-stream';
|
||||
|
@ -43,7 +42,7 @@ final class MimetypeTest extends RuleTestCase
|
|||
->expects(self::once())
|
||||
->method('file')
|
||||
->with($filename, FILEINFO_MIME_TYPE)
|
||||
->will(self::returnValue($mimetype));
|
||||
->willReturn($mimetype);
|
||||
|
||||
$rule = new Mimetype($mimetype, $fileInfoMock);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue