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

53 lines
1.6 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-stock立即购买库存校验店务
* TC-BUY-01TC-BUY-04
*/
use CompanysBundle\Services\OperatorFastBuyStockValidator;
use Dingo\Api\Exception\ResourceException;
class OperatorFastBuyStockValidatorTest extends TestCase
{
/**
* TC-BUY-01 / S3门店 0、云仓足够 → 通过(含较大 num 边界)。
*/
public function testTcBuy01ShopZeroPlatformEnoughPasses(): void
{
OperatorFastBuyStockValidator::validate(0, 100, 1);
OperatorFastBuyStockValidator::validate(0, 1000, 1000);
$this->addToAssertionCount(1);
}
/**
* TC-BUY-02 / S4门店>0 → 引导收银。
*/
public function testTcBuy02ShopHasStockThrowsCashierMessage(): void
{
$this->expectException(ResourceException::class);
$this->expectExceptionMessage('当前商品门店有库存,请从收银加购');
OperatorFastBuyStockValidator::validate(1, 999, 1);
}
/**
* TC-BUY-03 / S5双 0 → 库存不足。
*/
public function testTcBuy03BothZeroThrowsInsufficient(): void
{
$this->expectException(ResourceException::class);
$this->expectExceptionMessage('库存不足');
OperatorFastBuyStockValidator::validate(0, 0, 1);
}
/**
* TC-BUY-04 / S6云仓 n、num n+1 → 库存不足。
*/
public function testTcBuy04PlatformLessThanNumThrowsInsufficient(): void
{
$this->expectException(ResourceException::class);
$this->expectExceptionMessage('库存不足');
OperatorFastBuyStockValidator::validate(0, 5, 6);
}
}