feat: 更新开发环境配置,支持在 local 和 testing 环境下的玩家身份绕过,新增钱包余额 API 路由
This commit is contained in:
49
tests/Feature/WalletBalanceTest.php
Normal file
49
tests/Feature/WalletBalanceTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Player;
|
||||
use App\Models\PlayerWallet;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
test('wallet balance creates lottery wallet row and returns zeros', function () {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'test',
|
||||
'site_player_id' => 'p1',
|
||||
'username' => null,
|
||||
'nickname' => null,
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'Authorization' => 'Bearer dev:'.$player->id,
|
||||
'X-Locale' => 'zh',
|
||||
])->getJson('/api/v1/wallet/balance');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('code', 0)
|
||||
->assertJsonPath('data.balance', 0)
|
||||
->assertJsonPath('data.frozen_balance', 0)
|
||||
->assertJsonPath('data.currency_code', 'NPR')
|
||||
->assertJsonPath('data.wallet_type', 'lottery')
|
||||
->assertJsonPath('data.main_balance', null);
|
||||
|
||||
expect(PlayerWallet::query()->where('player_id', $player->id)->count())->toBe(1);
|
||||
});
|
||||
|
||||
test('wallet balance rejects illegal currency query', function () {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'test',
|
||||
'site_player_id' => 'p2',
|
||||
'username' => null,
|
||||
'nickname' => null,
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/balance?currency=!!')
|
||||
->assertStatus(400)
|
||||
->assertJsonPath('code', 1005);
|
||||
});
|
||||
Reference in New Issue
Block a user