46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Support\CreditorId;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class CreditorIdTest extends TestCase
|
|
{
|
|
public function test_normalizes_spaces_and_case(): void
|
|
{
|
|
$this->assertSame('DE98ZZZ09999999999', CreditorId::normalize(' de98 zzz 0999 9999 999 '));
|
|
}
|
|
|
|
public function test_accepts_the_bundesbank_test_id(): void
|
|
{
|
|
$this->assertTrue(CreditorId::isValid('DE98ZZZ09999999999'));
|
|
$this->assertTrue(CreditorId::isValid('de98 zzz 09999999999'));
|
|
}
|
|
|
|
public function test_business_code_does_not_affect_the_check_digit(): void
|
|
{
|
|
// Die Geschäftsbereichskennung (Stellen 5-7) wählt der Gläubiger selbst -- die Prüfziffer bleibt.
|
|
$this->assertTrue(CreditorId::isValid('DE98ABC09999999999'));
|
|
}
|
|
|
|
public function test_rejects_a_wrong_check_digit(): void
|
|
{
|
|
$this->assertFalse(CreditorId::isValid('DE97ZZZ09999999999'));
|
|
$this->assertFalse(CreditorId::isValid('DE98ZZZ09999999998'));
|
|
}
|
|
|
|
public function test_rejects_a_wrong_german_length(): void
|
|
{
|
|
$this->assertFalse(CreditorId::isValid('DE98ZZZ0999999999'));
|
|
$this->assertFalse(CreditorId::isValid('DE98ZZZ099999999990'));
|
|
}
|
|
|
|
public function test_rejects_malformed_input(): void
|
|
{
|
|
$this->assertFalse(CreditorId::isValid(''));
|
|
$this->assertFalse(CreditorId::isValid('DE02120300000000202051')); // eine IBAN
|
|
$this->assertFalse(CreditorId::isValid('DEXXZZZ09999999999'));
|
|
}
|
|
}
|