2023-02-06 00:07:37 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zoomyboy\LaravelNami\Tests\Unit\Api;
|
|
|
|
|
|
|
|
use Zoomyboy\LaravelNami\Data\Member;
|
|
|
|
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
|
|
|
use Zoomyboy\LaravelNami\Tests\TestCase;
|
|
|
|
|
|
|
|
class PutMemberTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testPushASingleMember(): void
|
|
|
|
{
|
|
|
|
app(MemberFake::class)->createsSuccessfully(103, 16);
|
2023-02-06 00:23:34 +01:00
|
|
|
$member = Member::factory()->toMember([
|
2023-02-06 00:07:37 +01:00
|
|
|
'firstname' => 'Max',
|
|
|
|
'lastname' => 'Nach1',
|
|
|
|
'nickname' => 'spitz1',
|
|
|
|
'groupId' => 103,
|
|
|
|
'genderId' => 17,
|
|
|
|
'confessionId' => 33,
|
|
|
|
'joinedAt' => '2021-02-02 00:00:00',
|
|
|
|
'birthday' => '2021-02-02 00:00:00',
|
|
|
|
'email' => 'aa@b.de',
|
|
|
|
'countryId' => 78,
|
|
|
|
'keepdata' => false,
|
|
|
|
'sendNewspaper' => false,
|
|
|
|
'regionId' => 11,
|
|
|
|
'nationalityId' => 12,
|
|
|
|
'beitragsartId' => null,
|
2023-02-06 01:11:14 +01:00
|
|
|
'emailParents' => 'a@b.de',
|
2023-02-06 01:24:20 +01:00
|
|
|
'location' => 'SG',
|
|
|
|
'zip' => 55555,
|
|
|
|
'address' => 'Maxstr 5',
|
|
|
|
'fax' => '+49 111',
|
|
|
|
'mainPhone' => '+49 222',
|
|
|
|
'mobilePhone' => '+49 333',
|
|
|
|
'workPhone' => '+49 3333',
|
|
|
|
'keepdata' => true,
|
|
|
|
'sendNewspaper' => true,
|
|
|
|
'otherCountry' => 'Land',
|
|
|
|
'furtherAddress' => 'Name',
|
|
|
|
'version' => 40,
|
2023-02-06 00:07:37 +01:00
|
|
|
]);
|
|
|
|
$response = $this->login()->putMember($member, 78, 79);
|
|
|
|
|
|
|
|
$this->assertEquals(16, $response);
|
|
|
|
|
|
|
|
app(MemberFake::class)->assertCreated(103, [
|
|
|
|
'spitzname' => 'spitz1',
|
|
|
|
'vorname' => 'Max',
|
|
|
|
'nachname' => 'Nach1',
|
|
|
|
'geschlechtId' => 17,
|
|
|
|
'email' => 'aa@b.de',
|
|
|
|
'beitragsartId' => null,
|
|
|
|
'geburtsDatum' => '2021-02-02 00:00:00',
|
|
|
|
'konfessionId' => 33,
|
|
|
|
'landId' => 78,
|
|
|
|
'wiederverwendenFlag' => false,
|
|
|
|
'zeitschriftenversand' => false,
|
|
|
|
'regionId' => 11,
|
|
|
|
'staatsangehoerigkeitId' => 12,
|
|
|
|
'ersteTaetigkeitId' => 78,
|
|
|
|
'ersteUntergliederungId' => 79,
|
2023-02-06 01:11:14 +01:00
|
|
|
'emailVertretungsberechtigter' => 'a@b.de',
|
2023-02-06 01:24:20 +01:00
|
|
|
'ort' => 'SG',
|
|
|
|
'plz' => '55555',
|
|
|
|
'strasse' => 'Maxstr 5',
|
|
|
|
'telefax' => '+49 111',
|
|
|
|
'telefon1' => '+49 222',
|
|
|
|
'telefon2' => '+49 333',
|
|
|
|
'telefon3' => '+49 3333',
|
|
|
|
'wiederverwendenFlag' => true,
|
|
|
|
'zeitschriftenversand' => true,
|
|
|
|
'staatsangehoerigkeitText' => 'Land',
|
|
|
|
'nameZusatz' => 'Name',
|
|
|
|
'version' => 40,
|
2023-02-06 00:07:37 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateAMemberWithForeignAttributes(): void
|
|
|
|
{
|
|
|
|
app(MemberFake::class)
|
|
|
|
->updatesSuccessfully(103, 16)
|
2023-02-06 00:23:34 +01:00
|
|
|
->shows(103, 16);
|
|
|
|
$member = Member::factory()->toMember([
|
2023-02-06 00:07:37 +01:00
|
|
|
'firstname' => 'Max',
|
|
|
|
'lastname' => 'Nach1',
|
|
|
|
'nickname' => 'spitz1',
|
|
|
|
'groupId' => 103,
|
|
|
|
'genderId' => 17,
|
|
|
|
'confessionId' => 33,
|
|
|
|
'joinedAt' => '2021-02-02 00:00:00',
|
|
|
|
'birthday' => '2021-02-02 00:00:00',
|
|
|
|
'email' => 'aa@b.de',
|
|
|
|
'countryId' => 78,
|
|
|
|
'keepdata' => false,
|
|
|
|
'sendNewspaper' => false,
|
|
|
|
'regionId' => 11,
|
|
|
|
'nationalityId' => 12,
|
|
|
|
'beitragsartId' => null,
|
|
|
|
'id' => 16,
|
|
|
|
]);
|
|
|
|
$response = $this->login()->putMember($member);
|
|
|
|
|
|
|
|
$this->assertEquals(16, $response);
|
|
|
|
|
|
|
|
app(MemberFake::class)->assertUpdated(103, 16, [
|
|
|
|
'spitzname' => 'spitz1',
|
|
|
|
'vorname' => 'Max',
|
|
|
|
'nachname' => 'Nach1',
|
|
|
|
'geschlechtId' => 17,
|
|
|
|
'email' => 'aa@b.de',
|
|
|
|
'beitragsartId' => null,
|
|
|
|
'geburtsDatum' => '2021-02-02 00:00:00',
|
|
|
|
'konfessionId' => 33,
|
|
|
|
'landId' => 78,
|
|
|
|
'wiederverwendenFlag' => false,
|
|
|
|
'zeitschriftenversand' => false,
|
|
|
|
'regionId' => 11,
|
|
|
|
'staatsangehoerigkeitId' => 12,
|
2023-02-06 00:23:34 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItMergesKontoverbindung(): void
|
|
|
|
{
|
|
|
|
app(MemberFake::class)
|
|
|
|
->updatesSuccessfully(103, 16)
|
|
|
|
->shows(103, 16, [
|
|
|
|
'foreign' => 'fff',
|
|
|
|
'kontoverbindung' => ['a' => 'b'],
|
|
|
|
]);
|
|
|
|
$response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember());
|
|
|
|
|
|
|
|
$this->assertEquals(16, $response);
|
|
|
|
|
|
|
|
app(MemberFake::class)->assertUpdated(103, 16, [
|
|
|
|
'kontoverbindung' => '{"a":"b"}',
|
2023-02-06 00:07:37 +01:00
|
|
|
'foreign' => 'fff',
|
|
|
|
]);
|
|
|
|
}
|
2023-02-07 00:56:12 +01:00
|
|
|
|
|
|
|
public function testGenderCanBeNull(): void
|
|
|
|
{
|
|
|
|
app(MemberFake::class)
|
|
|
|
->updatesSuccessfully(103, 16)
|
|
|
|
->shows(103, 16, [
|
|
|
|
'foreign' => 'fff',
|
|
|
|
'kontoverbindung' => ['a' => 'b'],
|
|
|
|
]);
|
2023-02-07 01:01:17 +01:00
|
|
|
$response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember(['genderId' => null, 'regionId' => null]));
|
2023-02-07 00:56:12 +01:00
|
|
|
|
|
|
|
$this->assertEquals(16, $response);
|
|
|
|
|
|
|
|
app(MemberFake::class)->assertUpdated(103, 16, [
|
|
|
|
'geschlechtId' => 23,
|
2023-02-07 01:01:17 +01:00
|
|
|
'regionId' => 23,
|
2023-02-07 00:56:12 +01:00
|
|
|
]);
|
|
|
|
}
|
2023-02-06 00:07:37 +01:00
|
|
|
}
|