This commit is contained in:
wanghai
2026-06-26 19:20:24 +08:00
parent 2e248de433
commit 058673559c
375 changed files with 34935 additions and 1361 deletions

View File

@@ -0,0 +1,52 @@
<?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);
}
}