Http::response([ 'id' => 101, 'login' => 'nico', 'full_name' => 'Nico Example', ]), ]); $authenticatedUser = app(GiteaProviderClient::class)->getAuthenticatedUser( 'https://git.example.test', 'super-secret-token', ); $this->assertInstanceOf(GitAuthenticatedUser::class, $authenticatedUser); $this->assertSame('101', $authenticatedUser->providerUserId); $this->assertSame('nico', $authenticatedUser->login); $this->assertSame('Nico Example', $authenticatedUser->name); Http::assertSent(function ($request): bool { return $request->url() === 'https://git.example.test/api/v1/user' && $request->hasHeader('Authorization', 'token super-secret-token'); }); } /** * Ensure the provider lists repositories from the authenticated Gitea account. */ public function test_provider_can_list_repositories(): void { Http::preventStrayRequests(); Http::fake([ 'https://git.example.test/api/v1/user/repos*' => Http::response([ [ 'id' => 501, 'name' => 'kanbangit', 'full_name' => 'nico/kanbangit', 'html_url' => 'https://git.example.test/nico/kanbangit', 'owner' => [ 'login' => 'nico', ], 'private' => false, ], ]), ]); $repositories = app(GiteaProviderClient::class)->listRepositories( 'https://git.example.test/api/v1', 'repo-token', ); $this->assertCount(1, $repositories); $this->assertContainsOnlyInstancesOf(GitRepository::class, $repositories); $this->assertSame('501', $repositories[0]->providerRepositoryId); $this->assertSame('nico/kanbangit', $repositories[0]->fullName); $this->assertFalse($repositories[0]->isPrivate); Http::assertSent(function ($request): bool { return str_starts_with($request->url(), 'https://git.example.test/api/v1/user/repos') && $request->hasHeader('Authorization', 'token repo-token'); }); } }