2023-02-08 00:14:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Member;
|
|
|
|
|
|
|
|
use App\Group;
|
2023-02-23 00:38:17 +01:00
|
|
|
use App\Member\Actions\InsertFullMemberAction;
|
|
|
|
use App\Member\Data\FullMember;
|
2023-02-08 00:14:59 +01:00
|
|
|
use App\Member\Member;
|
2023-02-23 00:38:17 +01:00
|
|
|
use App\Nami\Api\FullMemberAction;
|
2023-02-08 00:14:59 +01:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
2023-02-23 00:38:17 +01:00
|
|
|
use Zoomyboy\LaravelNami\Api;
|
|
|
|
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
2023-02-08 00:14:59 +01:00
|
|
|
|
|
|
|
class ResyncTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
2023-02-23 00:38:17 +01:00
|
|
|
private Api $api;
|
|
|
|
|
2023-02-08 00:14:59 +01:00
|
|
|
public function testItCanResyncAMember(): void
|
|
|
|
{
|
2023-02-23 00:38:17 +01:00
|
|
|
$this->api = $this->createStub(Api::class);
|
2023-02-08 00:14:59 +01:00
|
|
|
$this->login()->loginNami();
|
2023-02-23 00:38:17 +01:00
|
|
|
app(MemberFake::class)->shows(32, 33);
|
|
|
|
$fullMember = FullMember::from(['courses' => [], 'memberships' => [], 'member' => $this->api->member(32, 33)]);
|
|
|
|
FullMemberAction::shouldRun()->once()->andReturn($fullMember);
|
|
|
|
InsertFullMemberAction::shouldRun()->once();
|
2023-02-08 00:14:59 +01:00
|
|
|
$member = Member::factory()->defaults()->for(Group::factory()->inNami(32))->inNami(33)->create();
|
|
|
|
|
|
|
|
$response = $this->from('/member')->get(route('member.resync', ['member' => $member]));
|
|
|
|
|
|
|
|
$response->assertRedirect('/member');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|