Slide 57
Slide 57 text
#[Test]
public function fetchMyTeam_APIが_200_OK_を返す場合は手元のポケモン一覧を返す(): void
{
$httpClientMock = Mockery::mock(HttpClient::class);
$httpClientMock
->expects('get')
->with('/api/v2/my-team')
->andReturn(new Response(200, [], json_encode([
['name' => 'プリン', 'level' => 88, /* ... */],
// ...
])));
$subject = new PokemonService($httpClientMock);
$expected = [
new Pokemon(name: 'プリン', level: 88, /* ... */),
// ...
];
$actual = $subject->fetchMyTeam();
self::assertEquals($expected, $actual);
}
6. スパゲッティ・テスト