feat: 增强环境配置与开发服务,支持局域网访问及币种管理
This commit is contained in:
41
tests/Feature/PublicCurrencyIndexTest.php
Normal file
41
tests/Feature/PublicCurrencyIndexTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Currency;
|
||||
use App\Lottery\ErrorCode;
|
||||
use Database\Seeders\CurrencySeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function (): void {
|
||||
$this->seed(CurrencySeeder::class);
|
||||
});
|
||||
|
||||
test('public currency index returns enabled currencies with decimal places', function () {
|
||||
Currency::query()->create([
|
||||
'code' => 'JPY',
|
||||
'name' => 'Japanese Yen',
|
||||
'decimal_places' => 0,
|
||||
'is_enabled' => true,
|
||||
'is_bettable' => false,
|
||||
]);
|
||||
|
||||
Currency::query()->create([
|
||||
'code' => 'TEST',
|
||||
'name' => 'Disabled Currency',
|
||||
'decimal_places' => 4,
|
||||
'is_enabled' => false,
|
||||
'is_bettable' => false,
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/v1/currencies');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('code', ErrorCode::Success->value)
|
||||
->assertJsonCount(3, 'data.items')
|
||||
->assertJsonPath('data.items.0.code', 'NPR')
|
||||
->assertJsonPath('data.items.0.decimal_places', 2)
|
||||
->assertJsonPath('data.items.1.code', 'JPY')
|
||||
->assertJsonPath('data.items.1.decimal_places', 0)
|
||||
->assertJsonPath('data.items.2.code', 'USD');
|
||||
});
|
||||
Reference in New Issue
Block a user