Files
ECShopX/tests/PosPaymentVoucherValidatorTest.php
wanghai 058673559c 4.7.0
2026-06-26 19:20:24 +08:00

36 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* store-ops-buy-now-cloud-stockPOS 凭证 URL 校验TC-PAY-01、TC-PAY-02
*/
use Dingo\Api\Exception\ResourceException;
use PaymentBundle\Services\PosPaymentVoucherValidator;
class PosPaymentVoucherValidatorTest extends TestCase
{
/**
* TC-PAY-01合法 https URL 通过。
*/
public function testTcPay01ValidHttpsPasses(): void
{
PosPaymentVoucherValidator::validateNonEmpty('https://cdn.example.com/voucher/abc.png');
$this->addToAssertionCount(1);
}
/**
* TC-PAY-02非法 scheme 拒绝(不传凭证由调用方不调用本方法即可,等价于无凭证)。
*/
public function testTcPay02InvalidSchemeThrows(): void
{
$this->expectException(ResourceException::class);
PosPaymentVoucherValidator::validateNonEmpty('javascript:alert(1)');
}
public function testTooLongThrows(): void
{
$this->expectException(ResourceException::class);
PosPaymentVoucherValidator::validateNonEmpty('https://x.com/' . str_repeat('a', PosPaymentVoucherValidator::MAX_LENGTH));
}
}