adrema/tests/Feature/Member/NamiPutMemberActionTest.php

67 lines
2.2 KiB
PHP
Raw Normal View History

2022-11-16 23:39:44 +01:00
<?php
namespace Tests\Feature\Member;
2023-02-06 00:24:57 +01:00
use App\Actions\PullMemberAction;
2023-02-06 01:08:39 +01:00
use App\Actions\PullMembershipsAction;
2022-11-16 23:39:44 +01:00
use App\Activity;
use App\Confession;
use App\Country;
use App\Fee;
use App\Group;
use App\Member\Actions\NamiPutMemberAction;
use App\Member\Member;
use App\Nationality;
use App\Payment\Subscription;
use App\Region;
use App\Subactivity;
use Illuminate\Foundation\Testing\DatabaseTransactions;
2023-02-06 00:24:57 +01:00
use Phake;
2022-11-16 23:39:44 +01:00
use Tests\TestCase;
use Zoomyboy\LaravelNami\Fakes\MemberFake;
class NamiPutMemberActionTest extends TestCase
{
use DatabaseTransactions;
public function testItPutsAMember(): void
{
Fee::factory()->create();
2023-02-06 01:08:39 +01:00
$this->stubIo(PullMemberAction::class, fn ($mock) => $mock);
$this->stubIo(PullMembershipsAction::class, fn ($mock) => $mock);
2022-11-16 23:39:44 +01:00
$this->withoutExceptionHandling()->login()->loginNami();
$country = Country::factory()->create();
$region = Region::factory()->create();
$nationality = Nationality::factory()->inNami(565)->create();
$subscription = Subscription::factory()->create();
$group = Group::factory()->inNami(55)->create();
$confession = Confession::factory()->inNami(567)->create(['is_null' => true]);
app(MemberFake::class)->stores(55, 993);
2022-11-16 23:39:44 +01:00
$activity = Activity::factory()->hasAttached(Subactivity::factory()->name('Biber')->inNami(55))->name('Leiter')->inNami(6)->create();
$subactivity = $activity->subactivities->first();
$member = Member::factory()
->for($country)
->for($subscription)
->for($region)
->for($nationality)
->for($group)
2022-12-06 23:11:57 +01:00
->emailBillKind()
2023-02-06 01:25:41 +01:00
->create(['email_parents' => 'a@b.de']);
2022-11-16 23:39:44 +01:00
NamiPutMemberAction::run($member, $activity, $subactivity);
app(MemberFake::class)->assertStored(55, [
2022-11-16 23:39:44 +01:00
'ersteTaetigkeitId' => 6,
'ersteUntergliederungId' => 55,
'konfessionId' => 567,
2023-02-06 01:25:41 +01:00
'emailVertretungsberechtigter' => 'a@b.de',
2022-11-16 23:39:44 +01:00
]);
$this->assertDatabaseHas('members', [
'nami_id' => 993,
]);
2023-02-06 00:24:57 +01:00
Phake::verify(app(PullMemberAction::class))->handle(55, 993);
2023-02-06 01:08:39 +01:00
Phake::verify(app(PullMembershipsAction::class))->handle($member);
2022-11-16 23:39:44 +01:00
}
}