diff --git a/app/Member/DeleteJob.php b/app/Member/DeleteJob.php index ddd040d5..d1f3b7e0 100644 --- a/app/Member/DeleteJob.php +++ b/app/Member/DeleteJob.php @@ -21,7 +21,6 @@ class DeleteJob implements ShouldQueue public function __construct(Member $member) { $this->memberId = $member->id; - $this->user = $user; } /** diff --git a/tests/Feature/Member/DeleteTest.php b/tests/Feature/Member/DeleteTest.php new file mode 100644 index 00000000..ee197e34 --- /dev/null +++ b/tests/Feature/Member/DeleteTest.php @@ -0,0 +1,51 @@ +login()->loginNami(); + $member = Member::factory()->defaults()->inNami(123)->create(); + + $response = $this->from('/member')->delete("/member/{$member->id}"); + + $response->assertRedirect('/member'); + + Queue::assertPushed(DeleteJob::class, fn ($job) => $job->memberId === $member->id); + $this->assertDatabaseMissing('members', [ + 'id' => $member->id, + ]); + } + + public function testItDoesntRunActionWhenMemberIsNotInNami(): void + { + $this->login()->loginNami(); + $member = Member::factory()->defaults()->create(); + + $response = $this->from('/member')->delete("/member/{$member->id}"); + + $response->assertRedirect('/member'); + + Queue::assertNotPushed(DeleteJob::class); + $this->assertDatabaseMissing('members', [ + 'id' => $member->id, + ]); + } +}