refactor(pay): 重构账户余额查询接口并添加单元测试

- 创建 RequestHeaderBuilder Trait 以简化请求头构建逻辑
- 在 AccountBalanceRepo 中使用 RequestHeaderBuilder Trait
- 添加 QueryPointBalanceTest 单元测试用例
This commit is contained in:
李东云
2025-08-18 14:23:14 +08:00
parent 336cb3a9b9
commit 4f0d402538
3 changed files with 66 additions and 31 deletions

View File

@@ -0,0 +1,24 @@
<?php
/**
* QueryPointBalanceTest.php@Pay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2025/8/18
*/
use Singularity\HDK\Pay\Domain\Account\Aggregate\ValueObject\PointsBalance;
use Singularity\HDK\Pay\Domain\Account\Enum\PointType;
use Singularity\HDK\Pay\Infratracture\Repository\AccountBalanceRepo;
use function Hyperf\Support\make;
it('should query point balance', function () {
$uid = 'cn3221';
$repo = make(AccountBalanceRepo::class);
$point_balance = $repo->getPointBalance($uid, PointType::EMA);
expect($point_balance)
->toBeInstanceOf(PointsBalance::class)
->and($point_balance->getType())->toBe(PointType::EMA);
})->only();