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,69 @@
<?php
namespace Tests\Feature\Gateway;
use App\Models\User;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class GuildActionControllerTest extends TestCase
{
private function base(): string
{
return rtrim((string) config('services.backend.base'), '/');
}
private function actingUser()
{
if (class_exists(User::class) && method_exists(User::class, 'factory')) {
return User::factory()->make(['id' => 802, 'username' => 'guilduser', 'email_verified_at' => now()]);
}
return new class {
public $id = 802; public $username = 'guilduser'; public $role = 'User';
};
}
public function test_store_success()
{
Http::fake([
$this->base() . '/guilds' => Http::response([
'data' => ['id' => 1, 'name' => 'NewGuild', 'invite_code' => 'ABCDEF']
], 201),
]);
$res = $this->actingAs($this->actingUser())
->postJson('/guilds', [
'name' => 'NewGuild',
'tag' => 'ABCD',
]);
$res->assertStatus(201)
->assertJsonStructure(['data']);
}
public function test_join_success()
{
Http::fake([
$this->base() . '/guilds/join' => Http::response(['success' => true], 200),
]);
$res = $this->actingAs($this->actingUser())
->postJson('/guilds/join', [ 'invite_code' => 'AAAAAA' ]);
$res->assertStatus(200)
->assertJson(['success' => true]);
}
public function test_update_client_error_maps_to_client_error()
{
Http::fake([
$this->base() . '/guilds' => Http::response(['message' => 'Forbidden'], 403),
]);
$res = $this->actingAs($this->actingUser())
->patchJson('/guilds', [ 'name' => 'x' ]);
$res->assertStatus(403)
->assertJson(['message' => 'Forbidden']);
}
}