Fixed member deleteJob
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
8e7bf22f1b
commit
3385affe93
|
@ -21,7 +21,6 @@ class DeleteJob implements ShouldQueue
|
|||
public function __construct(Member $member)
|
||||
{
|
||||
$this->memberId = $member->id;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Member;
|
||||
|
||||
use App\Member\DeleteJob;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Queue::fake();
|
||||
}
|
||||
|
||||
public function testItDeletesMemberFromNami(): void
|
||||
{
|
||||
$this->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,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue