42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?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');
|
|
});
|