Initialer Laravel Commit für BetiX
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
2026-04-04 18:01:50 +02:00
commit 0280278978
374 changed files with 65210 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace Tests\Feature\Gateway;
use App\Models\User;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class UserBonusControllerTest extends TestCase
{
private function base(): string
{
return rtrim((string) config('services.backend.base'), '/');
}
private function actingUser()
{
return User::factory()->create(['username' => 'bonususer', 'email_verified_at' => now()]);
}
public function test_index_success_normalizes_data()
{
Http::fake([
$this->base() . '/users/me/bonuses' => Http::response([
'bonuses' => [
[
'id' => 9,
'amount' => 12.5,
'wager_required' => 100,
'wager_progress' => 40,
'expires_at' => now()->addDay()->toIso8601String(),
'is_active' => true,
'promo' => [ 'code' => 'WELCOME', 'wager_multiplier' => 40 ],
],
],
], 200),
]);
$res = $this->actingAs($this->actingUser(), 'web')->get('/api/user/bonuses');
$res->assertStatus(200)
->assertJsonStructure(['data' => [[
'id','amount','wager_required','wager_progress','expires_at','is_active','completed_at','promo'
]]]);
}
public function test_index_server_error_maps_to_503()
{
Http::fake([
$this->base() . '/users/me/bonuses' => Http::response(['message' => 'Down'], 500),
]);
$res = $this->actingAs($this->actingUser(), 'web')->get('/api/user/bonuses');
$res->assertStatus(503)->assertJson(['error' => 'service_unavailable']);
}
}