create(); $this->withoutExceptionHandling()->login()->loginNami(); $country = Country::factory()->create(); $gender = Gender::factory()->create(); $region = Region::factory()->create(); $nationality = Nationality::factory()->inNami(565)->create(); $subscription = Subscription::factory()->create(); $billKind = BillKind::factory()->create(); $group = Group::factory()->inNami(55)->create(); $confession = Confession::factory()->inNami(567)->create(['is_null' => true]); app(MemberFake::class)->createsSuccessfully(55, 993); $this->stubIo(MemberPullAction::class, fn ($mock) => $mock); $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($billKind) ->for($gender) ->for($group) ->create(); NamiPutMemberAction::run($member, $activity, $subactivity); app(MemberFake::class)->assertCreated(55, [ 'ersteTaetigkeitId' => 6, 'ersteUntergliederungId' => 55, 'konfessionId' => 567, ]); $this->assertDatabaseHas('members', [ 'nami_id' => 993, ]); } public function testItMergesExistingData(): void { $this->withoutExceptionHandling()->login()->loginNami(); $group = Group::factory()->inNami(55)->create(); $confession = Confession::factory()->inNami(567)->create(['is_null' => true]); $member = Member::factory() ->defaults() ->inNami(556) ->create(); $this->stubIo(MemberPullAction::class, fn ($mock) => $mock); app(MemberFake::class)->shows(55, 556, [ 'missingkey' => 'missingvalue', 'kontoverbindung' => ['a' => 'b'], ])->updates(55, 556, ['id' => 556]); NamiPutMemberAction::run($member, null, null); app(MemberFake::class)->assertUpdated(55, 556, [ 'kontoverbindung' => '{"a":"b"}', 'missingkey' => 'missingvalue', ]); $this->assertDatabaseHas('members', ['nami_id' => 556]); } }