47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Models\AdminUser;
|
|
use App\Models\JackpotPool;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
function mintSettlementAdminToken(): string
|
|
{
|
|
$admin = AdminUser::query()->create([
|
|
'username' => 'settlement_admin',
|
|
'name' => 'Settlement QA',
|
|
'email' => null,
|
|
'password' => Hash::make('secret-strong'),
|
|
'status' => 0,
|
|
]);
|
|
grantSuperAdminRole($admin);
|
|
|
|
return $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
|
}
|
|
|
|
test('admin settlement batches index is authenticated', function (): void {
|
|
$this->getJson('/api/v1/admin/settlement-batches')->assertUnauthorized();
|
|
});
|
|
|
|
test('admin jackpot pools index returns rows', function (): void {
|
|
JackpotPool::query()->create([
|
|
'currency_code' => 'NPR',
|
|
'current_amount' => 100,
|
|
'contribution_rate' => '0.01',
|
|
'trigger_threshold' => 1000,
|
|
'payout_rate' => '0.5',
|
|
'force_trigger_draw_gap' => 10,
|
|
'min_bet_amount' => 0,
|
|
'status' => 1,
|
|
'last_trigger_draw_id' => null,
|
|
]);
|
|
|
|
$token = mintSettlementAdminToken();
|
|
$this->withHeader('Authorization', 'Bearer '.$token)
|
|
->getJson('/api/v1/admin/jackpot/pools')
|
|
->assertOk()
|
|
->assertJsonPath('data.items.0.currency_code', 'NPR');
|
|
});
|