Fixed member deleteJob
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Philipp Lang 2022-09-05 10:57:20 +02:00
parent 8e7bf22f1b
commit 3385affe93
2 changed files with 51 additions and 1 deletions

View File

@ -21,7 +21,6 @@ class DeleteJob implements ShouldQueue
public function __construct(Member $member)
{
$this->memberId = $member->id;
$this->user = $user;
}
/**

View File

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