loginNami(); $member = Member::factory()->defaults()->create(); $api = app(NamiSettings::class)->login(); app(SearchFake::class)->fetches(1, 0, [ MemberEntry::factory()->toMember(['groupId' => 100, 'id' => 20]), ]); PullMemberAction::shouldRun()->once()->with(100, 20)->andReturn($member); PullMembershipsAction::shouldRun()->once()->with($member); PullCoursesAction::shouldRun()->once()->with($member); app(InitializeMembers::class)->handle($api); } public function testFetchesMembersWhenJoinedAtDateIsNull(): void { $this->loginNami(); $api = app(NamiSettings::class)->login(); app(SearchFake::class)->fetches(1, 0, [ MemberEntry::factory()->toMember(['groupId' => 100, 'id' => 20]), MemberEntry::factory()->toMember(['groupId' => 100, 'id' => 21]), ]); PullMemberAction::shouldRun()->once()->with(100, 20)->andThrow(MemberDataCorruptedException::class, []); PullMemberAction::shouldRun()->once()->with(100, 21); PullMembershipsAction::shouldRun()->once(); PullCoursesAction::shouldRun()->once(); app(InitializeMembers::class)->handle($api); } public function testFetchesMembersViaCommandLine(): void { $this->loginNami(); $api = app(NamiSettings::class)->login(); app(SearchFake::class)->fetches(1, 0, [ MemberEntry::factory()->toMember(['groupId' => 100, 'id' => 20]), ]); PullMemberAction::shouldRun()->once()->with(100, 20); PullMembershipsAction::shouldRun()->once(); PullCoursesAction::shouldRun()->once(); Artisan::call('member:pull'); } }