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']); } }