Add test for member deletion
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Philipp Lang 2022-09-05 11:37:54 +02:00
parent 3385affe93
commit 713496575c
3 changed files with 19 additions and 9 deletions

View File

@ -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);

@ -1 +1 @@
Subproject commit 6676b91cda3c0f426612768e5ae22396241cc488
Subproject commit 5ce86d632d3e228e08db314895aa9071e668f436

View File

@ -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);
}
}