Slide 45
Slide 45 text
5FTUJOH
public function testAccessTopPage()
{
// σʔλΞΫηεΫϥεͷϞοΫ࡞
$userMock = \Mockery::mock(\User::class);
$userMock->shouldReceive('getUsers')->andReturn('username');
// ϞοΫΫϥεΛBinding
$this->app->bind(\User::class, function () use ($userMock) {
return $userMock;
});
// ςετ࣮ߦ
$this->visit('/top')
->see('username')
->assertResponseOk();
}