mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
This commit introduces REUSE compliance by annotating all files with SPDX information and placing the reused licences in the LICENSES folder. We additionally removed the docheader tool which is made obsolete by this change. The main LICENSE and copyright text of the project is now not under my personal name anymore, and it belongs to "The Respect Project Contributors" instead. This change restores author names to several files, giving the appropriate attribution for contributions.
81 lines
2.1 KiB
PHP
81 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
* SPDX-FileContributor: Ville Hukkamäki <vhukkamaki@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Validators;
|
|
|
|
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('validator')]
|
|
#[CoversClass(Hetu::class)]
|
|
final class HetuTest extends TestCase
|
|
{
|
|
#[Test]
|
|
#[DataProvider('providerForNonStringTypes')]
|
|
public function itShouldAlwaysInvalidateWhenValueIsNotString(mixed $input): void
|
|
{
|
|
self::assertInvalidInput(new Hetu(), $input);
|
|
}
|
|
|
|
#[Test]
|
|
#[DataProvider('providerForInvalidHetu')]
|
|
public function itShouldInvalidateInvalidHetu(string $input): void
|
|
{
|
|
self::assertInvalidInput(new Hetu(), $input);
|
|
}
|
|
|
|
#[Test]
|
|
#[DataProvider('providerForValidHetu')]
|
|
public function itShouldValidateValidHetu(string $input): void
|
|
{
|
|
self::assertValidInput(new Hetu(), $input);
|
|
}
|
|
|
|
/** @return array<array{string}> */
|
|
public static function providerForValidHetu(): array
|
|
{
|
|
return [
|
|
['010106A9012'],
|
|
['290199-907A'],
|
|
['010199+9012'],
|
|
['280291+913L'],
|
|
['280291+923X'],
|
|
];
|
|
}
|
|
|
|
/** @return array<array{string}> */
|
|
public static function providerForInvalidHetu(): array
|
|
{
|
|
return [
|
|
['010106a9012'],
|
|
['010106_9012'],
|
|
['010106G9012'],
|
|
['010106Z9012'],
|
|
['010106A901G'],
|
|
['010106A901I'],
|
|
['010106A901O'],
|
|
['010106A901Q'],
|
|
['010106A901Z'],
|
|
['010106!9012'],
|
|
['010106'],
|
|
['01X199+9012'],
|
|
['01X199Z9012'],
|
|
['01X199T9012'],
|
|
['999999A9999'],
|
|
['999999A999F'],
|
|
['300201A1236'],
|
|
['290201A123J'],
|
|
];
|
|
}
|
|
}
|