26 lines
1.0 KiB
PHP
26 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Support\InnValidator;
|
||
|
|
|
||
|
|
it('validates 10-digit legal entity INN by checksum', function () {
|
||
|
|
expect(InnValidator::isValid('7707083893', 'legal_entity'))->toBeTrue(); // Сбербанк
|
||
|
|
expect(InnValidator::isValid('7707083890', 'legal_entity'))->toBeFalse(); // битая контр. цифра
|
||
|
|
expect(InnValidator::isValid('770708389', 'legal_entity'))->toBeFalse(); // 9 цифр
|
||
|
|
});
|
||
|
|
|
||
|
|
it('validates 12-digit sole proprietor INN by two checksums', function () {
|
||
|
|
expect(InnValidator::isValid('500100732259', 'sole_proprietor'))->toBeTrue();
|
||
|
|
expect(InnValidator::isValid('500100732250', 'sole_proprietor'))->toBeFalse();
|
||
|
|
expect(InnValidator::isValid('50010073225', 'sole_proprietor'))->toBeFalse(); // 11 цифр
|
||
|
|
});
|
||
|
|
|
||
|
|
it('does not require INN for individuals', function () {
|
||
|
|
expect(InnValidator::isValid('', 'individual'))->toBeTrue();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('rejects non-digit input', function () {
|
||
|
|
expect(InnValidator::isValid('77070838AB', 'legal_entity'))->toBeFalse();
|
||
|
|
});
|