public function EuropeanUnionVatTest::testValidate in Commerce Core 8.2
@covers ::validate
File
- modules/
tax/ tests/ src/ Kernel/ Plugin/ Commerce/ TaxNumberType/ EuropeanUnionVatTest.php, line 67
Class
- EuropeanUnionVatTest
- @coversDefaultClass \Drupal\commerce_tax\Plugin\Commerce\TaxNumberType\EuropeanUnionVat @group commerce
Namespace
Drupal\Tests\commerce_tax\Kernel\Plugin\Commerce\TaxNumberTypeCode
public function testValidate() {
$valid_numbers = [
'ATU13585626',
'BE0428759497',
'BG175074752',
'BG7523169263',
'CY10259033P',
'CZ25123891',
'CZ991231123',
'CZ7103192745',
'DE136695978',
'DK13585627',
'EE100594102',
'EL094259216',
'ES54362315K',
'ESX2482300W',
'ESB58378431',
'FI20774740',
'FR40303265045',
'FRK7399859412',
'HR33392005962',
'HU12892312',
'IE6433435F',
'IE6433435OA',
'IT00743110157',
'LT119511515',
'LT100001919017',
'LU15027442',
'LV16137519997',
'MT11679112',
'NL123456789B90',
'PL8567346215',
'PT501964842',
'RO18547291',
'SE123456789101',
'SI50223054',
'SK2022749618',
];
foreach ($valid_numbers as $number) {
$this
->assertTrue($this->plugin
->validate($number), $number);
}
$invalid_numbers = [
'AT13585626',
'ATX13585626',
'BE0428',
'DEABCDEFGHI',
'DK135856279',
];
foreach ($invalid_numbers as $number) {
$this
->assertFalse($this->plugin
->validate($number), $number);
}
// Confirm that a valid number without a prefix is not accepted.
$this
->assertFalse($this->plugin
->validate('U13585626'));
// Confirm that numbers are treated as case sensitive.
$this
->assertFalse($this->plugin
->validate('atU13585626'));
$this
->assertFalse($this->plugin
->validate('ATu13585626'));
}