This commit is contained in:
philipp lang 2024-11-07 00:38:28 +01:00
parent e807aff3e6
commit 24ed5d4ab9
1 changed files with 36 additions and 40 deletions

View File

@ -20,47 +20,43 @@ use Phake;
use Tests\TestCase; use Tests\TestCase;
use Zoomyboy\LaravelNami\Fakes\MemberFake; use Zoomyboy\LaravelNami\Fakes\MemberFake;
class NamiPutMemberActionTest extends TestCase uses(DatabaseTransactions::class);
{
use DatabaseTransactions;
public function testItPutsAMember(): void it('testItPutsAMember', function () {
{ Fee::factory()->create();
Fee::factory()->create(); $this->stubIo(PullMemberAction::class, fn ($mock) => $mock);
$this->stubIo(PullMemberAction::class, fn ($mock) => $mock); $this->stubIo(PullMembershipsAction::class, fn ($mock) => $mock);
$this->stubIo(PullMembershipsAction::class, fn ($mock) => $mock); $this->withoutExceptionHandling()->login()->loginNami();
$this->withoutExceptionHandling()->login()->loginNami(); $country = Country::factory()->create();
$country = Country::factory()->create(); $region = Region::factory()->create();
$region = Region::factory()->create(); $nationality = Nationality::factory()->inNami(565)->create();
$nationality = Nationality::factory()->inNami(565)->create(); $subscription = Subscription::factory()->forFee()->create();
$subscription = Subscription::factory()->forFee()->create(); $group = Group::factory()->inNami(55)->create();
$group = Group::factory()->inNami(55)->create(); $confession = Confession::factory()->inNami(567)->create(['is_null' => true]);
$confession = Confession::factory()->inNami(567)->create(['is_null' => true]); app(MemberFake::class)->stores(55, 993);
app(MemberFake::class)->stores(55, 993); $activity = Activity::factory()->hasAttached(Subactivity::factory()->name('Biber')->inNami(55))->name('Leiter')->inNami(6)->create();
$activity = Activity::factory()->hasAttached(Subactivity::factory()->name('Biber')->inNami(55))->name('Leiter')->inNami(6)->create(); $subactivity = $activity->subactivities->first();
$subactivity = $activity->subactivities->first();
$member = Member::factory() $member = Member::factory()
->for($country) ->for($country)
->for($subscription) ->for($subscription)
->for($region) ->for($region)
->for($nationality) ->for($nationality)
->for($group) ->for($group)
->emailBillKind() ->emailBillKind()
->create(['email_parents' => 'a@b.de']); ->create(['email_parents' => 'a@b.de']);
NamiPutMemberAction::run($member, $activity, $subactivity); NamiPutMemberAction::run($member, $activity, $subactivity);
app(MemberFake::class)->assertStored(55, [ app(MemberFake::class)->assertStored(55, [
'ersteTaetigkeitId' => 6, 'ersteTaetigkeitId' => 6,
'ersteUntergliederungId' => 55, 'ersteUntergliederungId' => 55,
'konfessionId' => 567, 'konfessionId' => 567,
'emailVertretungsberechtigter' => 'a@b.de', 'emailVertretungsberechtigter' => 'a@b.de',
]); ]);
$this->assertDatabaseHas('members', [ $this->assertDatabaseHas('members', [
'nami_id' => 993, 'nami_id' => 993,
]); ]);
Phake::verify(app(PullMemberAction::class))->handle(55, 993); Phake::verify(app(PullMemberAction::class))->handle(55, 993);
Phake::verify(app(PullMembershipsAction::class))->handle($member); Phake::verify(app(PullMembershipsAction::class))->handle($member);
} });
}