Add IBAN validator with QA workflows
PHP_CodeSniffer / PHP_CodeSniffer (push) Successful in 1m34s
PHPStan / PHPStan with PHP 8.5 prefer-lowest (push) Successful in 1m42s
PHPStan / PHPStan with PHP 8.1 prefer-stable (push) Successful in 1m56s
PHPStan / PHPStan with PHP 8.1 prefer-lowest (push) Successful in 1m56s
PHPStan / PHPStan with PHP 8.5 prefer-stable (push) Successful in 55s
PHPStan / PHPStan with PHP 8.6 prefer-source (push) Successful in 1m0s
PHPUnit / PHPUnit with PHP 8.1 prefer-lowest (push) Successful in 1m19s
PHPUnit / PHPUnit with PHP 8.1 prefer-stable (push) Successful in 1m23s
PHPUnit / PHPUnit with PHP 8.5 prefer-lowest (push) Successful in 55s
Smoke / Produce an output (push) Successful in 17s
PHPUnit / PHPUnit with PHP 8.5 prefer-stable (push) Successful in 57s
Smoke / Consume the output (push) Successful in 13s
PHPUnit / PHPUnit with PHP 8.6 prefer-source (push) Successful in 53s
PHP_CodeSniffer / PHP_CodeSniffer (push) Successful in 1m34s
PHPStan / PHPStan with PHP 8.5 prefer-lowest (push) Successful in 1m42s
PHPStan / PHPStan with PHP 8.1 prefer-stable (push) Successful in 1m56s
PHPStan / PHPStan with PHP 8.1 prefer-lowest (push) Successful in 1m56s
PHPStan / PHPStan with PHP 8.5 prefer-stable (push) Successful in 55s
PHPStan / PHPStan with PHP 8.6 prefer-source (push) Successful in 1m0s
PHPUnit / PHPUnit with PHP 8.1 prefer-lowest (push) Successful in 1m19s
PHPUnit / PHPUnit with PHP 8.1 prefer-stable (push) Successful in 1m23s
PHPUnit / PHPUnit with PHP 8.5 prefer-lowest (push) Successful in 55s
Smoke / Produce an output (push) Successful in 17s
PHPUnit / PHPUnit with PHP 8.5 prefer-stable (push) Successful in 57s
Smoke / Consume the output (push) Successful in 13s
PHPUnit / PHPUnit with PHP 8.6 prefer-source (push) Successful in 53s
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Systopia\PipelineTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \Systopia\PipelineTest\IbanValidator
|
||||
*/
|
||||
final class IbanValidatorTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider validIbans
|
||||
*/
|
||||
public function testAValidIban(string $iban): void {
|
||||
static::assertTrue((new IbanValidator())->isValid($iban));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{0: string}>
|
||||
*/
|
||||
public static function validIbans(): array {
|
||||
return [
|
||||
'germany' => ['DE89370400440532013000'],
|
||||
'grouped' => ['DE89 3704 0044 0532 0130 00'],
|
||||
'lowercase' => ['de89370400440532013000'],
|
||||
'austria' => ['AT611904300234573201'],
|
||||
'netherlands with letters' => ['NL91ABNA0417164300'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidIbans
|
||||
*/
|
||||
public function testAnInvalidIban(string $iban): void {
|
||||
static::assertFalse((new IbanValidator())->isValid($iban));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{0: string}>
|
||||
*/
|
||||
public static function invalidIbans(): array {
|
||||
return [
|
||||
'wrong checksum' => ['DE88370400440532013000'],
|
||||
'too short' => ['DE8937040044053201300'],
|
||||
'unknown country' => ['XX89370400440532013000'],
|
||||
'invalid character' => ['DE89370400440532013!00'],
|
||||
'empty' => [''],
|
||||
];
|
||||
}
|
||||
|
||||
public function testNormalizeStripsSeparatorsAndUppercases(): void {
|
||||
static::assertSame('DE89370400440532013000', (new IbanValidator())->normalize(' de89 3704-0044 0532 0130 00 '));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user