Files
lotteryLaravel/tests/Feature/FinancialChainAuditCommandTest.php
kang 2e0b257160
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
feat: enhance player authentication and agent management features
- Updated AGENTS.md to clarify player interface bindings and agent account restrictions.
- Improved PlayerAuthLoginController to include captcha verification for player login.
- Enhanced AdminPlayerIndexController with permission checks for admin users.
- Refactored AdminPlayerStoreController to enforce agent node restrictions for non-super admins.
- Introduced new error codes for player authentication failures and updated related services.
- Enhanced validation rules for agent profiles to include settlement cycle options.
- Improved AdminCaptchaService to support separate scopes for admin and player captcha handling.
- Updated various services to ensure proper credit management and settlement processes.
2026-06-17 15:27:00 +08:00

88 lines
2.6 KiB
PHP

<?php
use App\Models\Player;
use App\Models\PlayerWallet;
use App\Models\WalletTxn;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('financial chain audit passes for consistent wallet ledger', function (): void {
$player = Player::query()->create([
'site_code' => 'main',
'site_player_id' => 'financial-audit-ok',
'username' => 'financial_audit_ok',
'nickname' => null,
'default_currency' => 'NPR',
'status' => 0,
]);
$wallet = PlayerWallet::query()->create([
'player_id' => $player->id,
'wallet_type' => 'lottery',
'currency_code' => 'NPR',
'balance' => 1000,
'frozen_balance' => 0,
'status' => 0,
'version' => 1,
]);
WalletTxn::query()->create([
'txn_no' => 'WX_financial_audit_ok',
'player_id' => $player->id,
'wallet_id' => $wallet->id,
'biz_type' => 'manual_seed',
'biz_no' => 'manual_seed_ok',
'direction' => 1,
'amount' => 1000,
'balance_before' => 0,
'balance_after' => 1000,
'status' => 'posted',
'idempotent_key' => 'financial-audit-ok',
]);
$this->artisan('lottery:audit-financial-chain')
->expectsOutputToContain('Financial chain audit passed.')
->assertExitCode(0);
});
test('financial chain audit reports wallet balance drift', function (): void {
$player = Player::query()->create([
'site_code' => 'main',
'site_player_id' => 'financial-audit-bad',
'username' => 'financial_audit_bad',
'nickname' => null,
'default_currency' => 'NPR',
'status' => 0,
]);
$wallet = PlayerWallet::query()->create([
'player_id' => $player->id,
'wallet_type' => 'lottery',
'currency_code' => 'NPR',
'balance' => 900,
'frozen_balance' => 0,
'status' => 0,
'version' => 1,
]);
WalletTxn::query()->create([
'txn_no' => 'WX_financial_audit_bad',
'player_id' => $player->id,
'wallet_id' => $wallet->id,
'biz_type' => 'manual_seed',
'biz_no' => 'manual_seed_bad',
'direction' => 1,
'amount' => 1000,
'balance_before' => 0,
'balance_after' => 1000,
'status' => 'posted',
'idempotent_key' => 'financial-audit-bad',
]);
$this->artisan('lottery:audit-financial-chain')
->expectsOutputToContain('Financial chain audit found')
->expectsOutputToContain('[wallet_latest_mismatch]')
->assertExitCode(1);
});