Initialer Laravel Commit für BetiX
This commit is contained in:
53
tests/Feature/Gateway/GuildControllerTest.php
Normal file
53
tests/Feature/Gateway/GuildControllerTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Gateway;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GuildControllerTest 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' => 801, 'username' => 'guilduser']);
|
||||
}
|
||||
return new class {
|
||||
public $id = 801; public $username = 'guilduser'; public $role = 'User';
|
||||
};
|
||||
}
|
||||
|
||||
public function test_index_renders_with_upstream_data()
|
||||
{
|
||||
Http::fake([
|
||||
$this->base() . '/guilds' => Http::response([
|
||||
'guild' => ['id' => 1, 'name' => 'Testers'],
|
||||
'myRole' => 'member',
|
||||
'canManage' => false,
|
||||
'invite' => 'AAAAAA',
|
||||
'wager' => ['value' => 0],
|
||||
'topPlayers' => [],
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$res = $this->actingAs($this->actingUser())->get('/guilds');
|
||||
$res->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_top_renders_list()
|
||||
{
|
||||
Http::fake([
|
||||
$this->base() . '/guilds/top' => Http::response([
|
||||
'guilds' => [ ['id' => 1, 'name' => 'A'], ['id' => 2, 'name' => 'B'] ],
|
||||
], 200),
|
||||
]);
|
||||
$res = $this->actingAs($this->actingUser())->get('/guilds/top');
|
||||
$res->assertStatus(200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user