From 713496575c8258c917e61285a792ed5c7acc48ec Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Mon, 5 Sep 2022 11:37:54 +0200 Subject: [PATCH] Add test for member deletion --- app/Member/DeleteJob.php | 3 ++- packages/laravel-nami | 2 +- tests/Feature/Member/DeleteTest.php | 23 ++++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/Member/DeleteJob.php b/app/Member/DeleteJob.php index d1f3b7e0..f55803a9 100644 --- a/app/Member/DeleteJob.php +++ b/app/Member/DeleteJob.php @@ -2,6 +2,7 @@ namespace App\Member; +use App\Setting\NamiSettings; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -28,7 +29,7 @@ class DeleteJob implements ShouldQueue * * @return void */ - public function handle() + public function handle(NamiSettings $setting) { $this->member = Member::find($this->memberId); diff --git a/packages/laravel-nami b/packages/laravel-nami index 6676b91c..5ce86d63 160000 --- a/packages/laravel-nami +++ b/packages/laravel-nami @@ -1 +1 @@ -Subproject commit 6676b91cda3c0f426612768e5ae22396241cc488 +Subproject commit 5ce86d632d3e228e08db314895aa9071e668f436 diff --git a/tests/Feature/Member/DeleteTest.php b/tests/Feature/Member/DeleteTest.php index ee197e34..0cbce3cb 100644 --- a/tests/Feature/Member/DeleteTest.php +++ b/tests/Feature/Member/DeleteTest.php @@ -4,23 +4,19 @@ namespace Tests\Feature\Member; use App\Member\DeleteJob; use App\Member\Member; +use Carbon\Carbon; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Queue; use Tests\TestCase; +use Zoomyboy\LaravelNami\Fakes\MemberFake; class DeleteTest extends TestCase { use DatabaseTransactions; - public function setUp(): void - { - parent::setUp(); - - Queue::fake(); - } - public function testItDeletesMemberFromNami(): void { + Queue::fake(); $this->login()->loginNami(); $member = Member::factory()->defaults()->inNami(123)->create(); @@ -36,6 +32,7 @@ class DeleteTest extends TestCase public function testItDoesntRunActionWhenMemberIsNotInNami(): void { + Queue::fake(); $this->login()->loginNami(); $member = Member::factory()->defaults()->create(); @@ -48,4 +45,16 @@ class DeleteTest extends TestCase 'id' => $member->id, ]); } + + public function testTheActionDeletesNamiMember(): void + { + app(MemberFake::class)->deletes(123, Carbon::parse('yesterday')); + $this->withoutExceptionHandling()->login()->loginNami(); + $member = Member::factory()->defaults()->inNami(123)->create(); + + dispatch(new DeleteJob($member)); + + app(MemberFake::class)->assertDeleted(123, Carbon::parse('yesterday')); + $this->assertNull($member->fresh()->nami_id); + } }