Compare commits
	
		
			1 Commits
		
	
	
		
			22aa303311
			...
			48881ef4ed
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 48881ef4ed | 
|  | @ -93,11 +93,6 @@ class MemberFactory extends Factory | ||||||
|         return $this->state(['nami_id' => $namiId]); |         return $this->state(['nami_id' => $namiId]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function notInNami(): self |  | ||||||
|     { |  | ||||||
|         return $this->state(['nami_id' => null]); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function withBankAccount(BankAccountFactory $factory): self |     public function withBankAccount(BankAccountFactory $factory): self | ||||||
|     { |     { | ||||||
|         return $this->afterCreating(function ($member) use ($factory) { |         return $this->afterCreating(function ($member) use ($factory) { | ||||||
|  |  | ||||||
|  | @ -92,6 +92,8 @@ services: | ||||||
| 
 | 
 | ||||||
|     socketi: |     socketi: | ||||||
|         image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian |         image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian | ||||||
|  |         ports: | ||||||
|  |             - '6001:6001' | ||||||
|         environment: |         environment: | ||||||
|             SOKETI_DEFAULT_APP_ID: adremaid |             SOKETI_DEFAULT_APP_ID: adremaid | ||||||
|             SOKETI_DEFAULT_APP_KEY: adremakey |             SOKETI_DEFAULT_APP_KEY: adremakey | ||||||
|  | @ -104,6 +106,8 @@ services: | ||||||
| 
 | 
 | ||||||
|     meilisearch: |     meilisearch: | ||||||
|         image: getmeili/meilisearch:v1.6 |         image: getmeili/meilisearch:v1.6 | ||||||
|  |         ports: | ||||||
|  |             - '7700:7700' | ||||||
|         volumes: |         volumes: | ||||||
|             - ./data/meilisearch:/meili_data |             - ./data/meilisearch:/meili_data | ||||||
|         env_file: |         env_file: | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| Subproject commit f905c316ee7913cbf85c386021fbaa28b4b2a158 | Subproject commit 7189511a550ecce5c9b8f6a0b31e3b4e011752a2 | ||||||
|  | @ -6,95 +6,69 @@ use App\Actions\PullMemberAction; | ||||||
| use App\Actions\PullMembershipsAction; | use App\Actions\PullMembershipsAction; | ||||||
| use App\Activity; | use App\Activity; | ||||||
| use App\Confession; | use App\Confession; | ||||||
|  | use App\Country; | ||||||
|  | use App\Fee; | ||||||
| use App\Group; | use App\Group; | ||||||
| use App\Member\Actions\NamiPutMemberAction; | use App\Member\Actions\NamiPutMemberAction; | ||||||
| use App\Member\Member; | use App\Member\Member; | ||||||
|  | use App\Nationality; | ||||||
|  | use App\Payment\Subscription; | ||||||
| use App\Subactivity; | use App\Subactivity; | ||||||
| use Illuminate\Foundation\Testing\DatabaseTransactions; | use Illuminate\Foundation\Testing\DatabaseTransactions; | ||||||
| use Illuminate\Support\Facades\Http; | use Illuminate\Support\Facades\Http; | ||||||
| use Tests\RequestFactories\MemberUpdateRequestFactory; | use Tests\TestCase; | ||||||
| use Zoomyboy\LaravelNami\Fakes\MemberFake; | use Zoomyboy\LaravelNami\Fakes\MemberFake; | ||||||
| 
 | 
 | ||||||
| uses(DatabaseTransactions::class); | class UpdateTest extends TestCase | ||||||
| 
 |  | ||||||
| function singleMemberUrl(int $gruppierungId, int $memberId): string |  | ||||||
| { | { | ||||||
|     return "https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/{$gruppierungId}/{$memberId}"; |     use DatabaseTransactions; | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| beforeEach(function () { |     public function testItRedirectsToMemberOverview(): void | ||||||
|     Confession::factory()->create(['is_null' => true]); |  | ||||||
| }); |  | ||||||
| 
 |  | ||||||
| function fakeRequest(): void |  | ||||||
|     { |     { | ||||||
|     Http::fake(function ($request) { |  | ||||||
|         if ($request->url() === singleMemberUrl(10, 135) && 'GET' === $request->method()) { |  | ||||||
|             return Http::response('{ "success": true, "data": {"missingkey": "missingvalue", "kontoverbindung": {"a": "b"} } }', 200); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if ($request->url() === singleMemberUrl(10, 135) && 'PUT' === $request->method() && 43 === $request['version']) { |  | ||||||
|             return Http::response('{ "success": false, "message": "Update nicht möglich. Der Datensatz wurde zwischenzeitlich verändert." }', 200); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if ($request->url() === singleMemberUrl(10, 135) && 'PUT' === $request->method()) { |  | ||||||
|             return Http::response('{ "success": true, "data": { "version": 44 } }', 200); |  | ||||||
|         } |  | ||||||
|     }); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| function factory() |  | ||||||
| { |  | ||||||
|     return Member::factory() |  | ||||||
|         ->defaults() |  | ||||||
|         ->for(Group::factory()->state(['nami_id' => 10])) |  | ||||||
|         ->state(['nami_id' => 135]); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| it('calls put action', function () { |  | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->create(); |         $member = $this->member(); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
|         NamiPutMemberAction::allowToRun(); |         NamiPutMemberAction::allowToRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create()); |         $response = $this | ||||||
|  |             ->from("/member/{$member->id}") | ||||||
|  |             ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'bank_account' => []])); | ||||||
| 
 | 
 | ||||||
|  |         $response->assertRedirect('/member'); | ||||||
|         NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs( |         NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs( | ||||||
|             fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member) |             fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member) | ||||||
|                 && null === $activityParam |                 && null === $activityParam | ||||||
|                 && null === $subactivityParam |                 && null === $subactivityParam | ||||||
|         )->once(); |         )->once(); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('redirects to member overview', function () { |     public function testItChecksVersion(): void | ||||||
|     $this->withoutExceptionHandling()->login()->loginNami(); |     { | ||||||
|     $member = factory()->create(); |  | ||||||
|     fakeRequest(); |  | ||||||
|     NamiPutMemberAction::allowToRun(); |  | ||||||
| 
 |  | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create()) |  | ||||||
|         ->assertRedirect('/member'); |  | ||||||
| }); |  | ||||||
| 
 |  | ||||||
| it('testItChecksVersion', function () { |  | ||||||
|         $this->login()->loginNami()->withoutExceptionHandling(); |         $this->login()->loginNami()->withoutExceptionHandling(); | ||||||
|     $member = tap(factory()->create(), fn ($member) => $member->update(['version' => 43])); |         $member = $this->member(); | ||||||
|     fakeRequest(); |         $member->update(['version' => 43]); | ||||||
|  |         $this->fakeRequest(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), MemberUpdateRequestFactory::new()->create())) |         $response = $this | ||||||
|         ->assertRedirect("/member/{$member->id}/edit?conflict=1"); |             ->from("/member/{$member->id}") | ||||||
| }); |             ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::', 'bank_account' => []])); | ||||||
| 
 | 
 | ||||||
| it('testItUpdatesPhoneNumber', function () { |         $response->assertRedirect("/member/{$member->id}/edit?conflict=1"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function testItUpdatesPhoneNumber(): void | ||||||
|  |     { | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->create(); |         $member = $this->member(); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
|         NamiPutMemberAction::allowToRun(); |         NamiPutMemberAction::allowToRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create([ |         $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ | ||||||
|  |             'bank_account' => [], | ||||||
|             'main_phone' => '02103 4455129', |             'main_phone' => '02103 4455129', | ||||||
|             'fax' => '02103 4455130', |             'fax' => '02103 4455130', | ||||||
|             'children_phone' => '02103 4455130', |             'children_phone' => '02103 4455130', | ||||||
|  |             'has_nami' => true, | ||||||
|         ])); |         ])); | ||||||
| 
 | 
 | ||||||
|         $this->assertDatabaseHas('members', [ |         $this->assertDatabaseHas('members', [ | ||||||
|  | @ -102,77 +76,82 @@ it('testItUpdatesPhoneNumber', function () { | ||||||
|             'fax' => '+49 2103 4455130', |             'fax' => '+49 2103 4455130', | ||||||
|             'children_phone' => '+49 2103 4455130', |             'children_phone' => '+49 2103 4455130', | ||||||
|         ]); |         ]); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItUpdatesBankAccount', function () { |     public function testItUpdatesKontoverbindung(): void | ||||||
|  |     { | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->create(); |         $member = $this->member(); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
|         NamiPutMemberAction::allowToRun(); |         NamiPutMemberAction::allowToRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create([ |         $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ | ||||||
|         'bank_account' => [ |             'bank_account' => ['iban' => 'SSS', 'bic' => 'AAA'], | ||||||
|             'iban' => 'DE1122', |             'has_nami' => true, | ||||||
|             'bic' => 'SOLSDE', |  | ||||||
|             'person' => 'Max' |  | ||||||
|         ] |  | ||||||
|         ])); |         ])); | ||||||
| 
 | 
 | ||||||
|         $this->assertDatabaseHas('bank_accounts', [ |         $this->assertDatabaseHas('bank_accounts', [ | ||||||
|         'iban' => 'DE1122', |  | ||||||
|         'bic' => 'SOLSDE', |  | ||||||
|         'person' => 'Max', |  | ||||||
|             'member_id' => $member->id, |             'member_id' => $member->id, | ||||||
|  |             'iban' => 'SSS', | ||||||
|  |             'bic' => 'AAA', | ||||||
|         ]); |         ]); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItUpdatesWiederverwendenFlag', function () { |     public function testItUpdatesWiederverwendenFlag(): void | ||||||
|  |     { | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->create(); |         $member = $this->member(); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
|         NamiPutMemberAction::allowToRun(); |         NamiPutMemberAction::allowToRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create([ |         $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ | ||||||
|  |             'bank_account' => [], | ||||||
|             'keepdata' => true, |             'keepdata' => true, | ||||||
|  |             'has_nami' => true, | ||||||
|         ])); |         ])); | ||||||
| 
 | 
 | ||||||
|         $this->assertDatabaseHas('members', [ |         $this->assertDatabaseHas('members', [ | ||||||
|             'keepdata' => true, |             'keepdata' => true, | ||||||
|         ]); |         ]); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItSetsLocationToNull', function () { |     public function testItSetsLocationToNull(): void | ||||||
|  |     { | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->notInNami()->create(['location' => 'Hilden']); |         $member = $this->member(['location' => 'Hilden', 'nami_id' => null]); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
|         NamiPutMemberAction::allowToRun(); |         NamiPutMemberAction::allowToRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->noNami()->create([ |         $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ | ||||||
|  |             'bank_account' => [], | ||||||
|             'location' => null, |             'location' => null, | ||||||
|         'bank_account' => [] |  | ||||||
|         ])); |         ])); | ||||||
| 
 | 
 | ||||||
|         $this->assertDatabaseHas('members', [ |         $this->assertDatabaseHas('members', [ | ||||||
|             'location' => null, |             'location' => null, | ||||||
|         ]); |         ]); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItUpdatesContact', function () { |     public function testItUpdatesContact(): void | ||||||
|  |     { | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->notInNami()->create(); |         $member = $this->member(['nami_id' => null]); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->noNami()->create([ |         $response = $this | ||||||
|  |             ->from("/member/{$member->id}") | ||||||
|  |             ->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ | ||||||
|  |                 'bank_account' => [], | ||||||
|                 'other_country' => 'englisch', |                 'other_country' => 'englisch', | ||||||
|         'bank_account' => [] |  | ||||||
|             ])); |             ])); | ||||||
| 
 | 
 | ||||||
|         $this->assertEquals('englisch', $member->fresh()->other_country); |         $this->assertEquals('englisch', $member->fresh()->other_country); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItCreatesMemberWithFirstActivityId', function () { |     public function testItCreatesMemberWithFirstActivityId(): void | ||||||
|  |     { | ||||||
|         $this->login()->loginNami()->withoutExceptionHandling(); |         $this->login()->loginNami()->withoutExceptionHandling(); | ||||||
|     $member = factory()->new()->defaults()->create(); |         $member = Member::factory()->defaults()->create(); | ||||||
|         app(MemberFake::class)->stores($member->group->nami_id, 103); |         app(MemberFake::class)->stores($member->group->nami_id, 103); | ||||||
|         $activity = Activity::factory()->inNami(89)->create(); |         $activity = Activity::factory()->inNami(89)->create(); | ||||||
|         $subactivity = Subactivity::factory()->inNami(90)->create(); |         $subactivity = Subactivity::factory()->inNami(90)->create(); | ||||||
|  | @ -180,41 +159,50 @@ it('testItCreatesMemberWithFirstActivityId', function () { | ||||||
|         PullMemberAction::shouldRun(); |         PullMemberAction::shouldRun(); | ||||||
|         PullMembershipsAction::shouldRun(); |         PullMembershipsAction::shouldRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create([ |         $this->patch("/member/{$member->id}", [ | ||||||
|  |             ...$member->getAttributes(), | ||||||
|  |             'bank_account' => [], | ||||||
|  |             'has_nami' => true, | ||||||
|             'first_activity_id' => $activity->id, |             'first_activity_id' => $activity->id, | ||||||
|             'first_subactivity_id' => $subactivity->id, |             'first_subactivity_id' => $subactivity->id, | ||||||
|     ]))->assertSessionHasNoErrors(); |         ])->assertSessionHasNoErrors(); | ||||||
| 
 | 
 | ||||||
|         app(MemberFake::class)->assertStored($member->group->nami_id, [ |         app(MemberFake::class)->assertStored($member->group->nami_id, [ | ||||||
|             'ersteTaetigkeitId' => 89, |             'ersteTaetigkeitId' => 89, | ||||||
|             'ersteUntergliederungId' => 90, |             'ersteUntergliederungId' => 90, | ||||||
|         ]); |         ]); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItRequiresFirstActivityId', function () { |     public function testItRequiresFirstActivityId(): void | ||||||
|  |     { | ||||||
|         $this->login()->loginNami(); |         $this->login()->loginNami(); | ||||||
|     $member = factory()->new()->defaults()->create(); |         $member = Member::factory()->defaults()->create(); | ||||||
|         app(MemberFake::class)->stores($member->group->nami_id, 103); |         app(MemberFake::class)->stores($member->group->nami_id, 103); | ||||||
|         Confession::factory()->create(['is_null' => true]); |         Confession::factory()->create(['is_null' => true]); | ||||||
|         PullMemberAction::shouldRun(); |         PullMemberAction::shouldRun(); | ||||||
|         PullMembershipsAction::shouldRun(); |         PullMembershipsAction::shouldRun(); | ||||||
| 
 | 
 | ||||||
|     $this->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->create([ |         $this->patch("/member/{$member->id}", [ | ||||||
|  |             ...$member->getAttributes(), | ||||||
|  |             'has_nami' => true, | ||||||
|             'first_activity_id' => null, |             'first_activity_id' => null, | ||||||
|             'first_subactivity_id' => null, |             'first_subactivity_id' => null, | ||||||
|     ]))->assertSessionHasErrors([ |         ])->assertSessionHasErrors([ | ||||||
|             'first_activity_id' => 'Erste Tätigkeit ist erforderlich.', |             'first_activity_id' => 'Erste Tätigkeit ist erforderlich.', | ||||||
|             'first_subactivity_id' => 'Erste Untergliederung ist erforderlich.', |             'first_subactivity_id' => 'Erste Untergliederung ist erforderlich.', | ||||||
|         ]); |         ]); | ||||||
| }); |     } | ||||||
| 
 | 
 | ||||||
| it('testItUpdatesCriminalRecord', function () { |     public function testItUpdatesCriminalRecord(): void | ||||||
|  |     { | ||||||
|         $this->withoutExceptionHandling()->login()->loginNami(); |         $this->withoutExceptionHandling()->login()->loginNami(); | ||||||
|     $member = factory()->notInNami()->create(); |         $member = $this->member(['nami_id' => null]); | ||||||
|     fakeRequest(); |         $this->fakeRequest(); | ||||||
| 
 | 
 | ||||||
|     $this |         $response = $this | ||||||
|         ->patch("/member/{$member->id}", MemberUpdateRequestFactory::new()->noNami()->create([ |             ->from("/member/{$member->id}") | ||||||
|  |             ->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ | ||||||
|  |                 'bank_account' => [], | ||||||
|                 'ps_at' => '2021-02-01', |                 'ps_at' => '2021-02-01', | ||||||
|                 'more_ps_at' => '2021-02-02', |                 'more_ps_at' => '2021-02-02', | ||||||
|                 'has_svk' => true, |                 'has_svk' => true, | ||||||
|  | @ -227,7 +215,6 @@ it('testItUpdatesCriminalRecord', function () { | ||||||
|                 'multiply_pv' => true, |                 'multiply_pv' => true, | ||||||
|                 'multiply_more_pv' => true, |                 'multiply_more_pv' => true, | ||||||
|                 'salutation' => 'Doktor', |                 'salutation' => 'Doktor', | ||||||
|             'bank_account' => [] |  | ||||||
|             ])); |             ])); | ||||||
| 
 | 
 | ||||||
|         $this->assertEquals('2021-02-01', $member->fresh()->ps_at->format('Y-m-d')); |         $this->assertEquals('2021-02-01', $member->fresh()->ps_at->format('Y-m-d')); | ||||||
|  | @ -241,4 +228,41 @@ it('testItUpdatesCriminalRecord', function () { | ||||||
|         $this->assertEquals('2021-02-05', $member->fresh()->without_efz_at->format('Y-m-d')); |         $this->assertEquals('2021-02-05', $member->fresh()->without_efz_at->format('Y-m-d')); | ||||||
|         $this->assertEquals('2021-02-08', $member->fresh()->recertified_at->format('Y-m-d')); |         $this->assertEquals('2021-02-08', $member->fresh()->recertified_at->format('Y-m-d')); | ||||||
|         $this->assertEquals('Doktor', $member->fresh()->salutation); |         $this->assertEquals('Doktor', $member->fresh()->salutation); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @param array<string, string|Activity|null> $overwrites | ||||||
|  |      */ | ||||||
|  |     private function member(array $overwrites = []): Member | ||||||
|  |     { | ||||||
|  |         return Member::factory() | ||||||
|  |             ->for(Group::factory()->state(['nami_id' => 10])) | ||||||
|  |             ->for(Confession::factory()) | ||||||
|  |             ->for(Nationality::factory()) | ||||||
|  |             ->for(Subscription::factory()->forFee()) | ||||||
|  |             ->for(Country::factory()) | ||||||
|  |             ->create(['nami_id' => 135, ...$overwrites]); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private function fakeRequest(): void | ||||||
|  |     { | ||||||
|  |         Http::fake(function ($request) { | ||||||
|  |             if ($request->url() === $this->singleMemberUrl(10, 135) && 'GET' === $request->method()) { | ||||||
|  |                 return Http::response('{ "success": true, "data": {"missingkey": "missingvalue", "kontoverbindung": {"a": "b"} } }', 200); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ($request->url() === $this->singleMemberUrl(10, 135) && 'PUT' === $request->method() && 43 === $request['version']) { | ||||||
|  |                 return Http::response('{ "success": false, "message": "Update nicht möglich. Der Datensatz wurde zwischenzeitlich verändert." }', 200); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if ($request->url() === $this->singleMemberUrl(10, 135) && 'PUT' === $request->method()) { | ||||||
|  |                 return Http::response('{ "success": true, "data": { "version": 44 } }', 200); | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private function singleMemberUrl(int $gruppierungId, int $memberId): string | ||||||
|  |     { | ||||||
|  |         return "https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/{$gruppierungId}/{$memberId}"; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -2,9 +2,6 @@ | ||||||
| 
 | 
 | ||||||
| namespace Tests\RequestFactories; | namespace Tests\RequestFactories; | ||||||
| 
 | 
 | ||||||
| use App\Country; |  | ||||||
| use App\Nationality; |  | ||||||
| use App\Payment\Subscription; |  | ||||||
| use Worksome\RequestFactories\RequestFactory; | use Worksome\RequestFactories\RequestFactory; | ||||||
| 
 | 
 | ||||||
| class MemberRequestFactory extends RequestFactory | class MemberRequestFactory extends RequestFactory | ||||||
|  | @ -14,18 +11,14 @@ class MemberRequestFactory extends RequestFactory | ||||||
|      */ |      */ | ||||||
|     public function definition(): array |     public function definition(): array | ||||||
|     { |     { | ||||||
|         $country = Country::factory()->create(); |  | ||||||
|         $nationality = Nationality::factory()->create(); |  | ||||||
|         $subscription = Subscription::factory()->forFee()->create(); |  | ||||||
| 
 |  | ||||||
|         return [ |         return [ | ||||||
|             'address' => 'Bavert 50', |             'address' => 'Bavert 50', | ||||||
|             'birthday' => '2013-02-19', |             'birthday' => '2013-02-19', | ||||||
|             'children_phone' => '+49 176 70512778', |             'children_phone' => '+49 123 44444', | ||||||
|             'efz' => '', |             'efz' => '', | ||||||
|             'email' => '', |             'email' => '', | ||||||
|             'email_parents' => 'osloot@aol.com', |             'email_parents' => 'osloot@aol.com', | ||||||
|             'fax' => '+49 212 4732223', |             'fax' => '+49 666', | ||||||
|             'firstname' => 'Joe', |             'firstname' => 'Joe', | ||||||
|             'further_address' => '', |             'further_address' => '', | ||||||
|             'has_nami' => true, |             'has_nami' => true, | ||||||
|  | @ -35,8 +28,8 @@ class MemberRequestFactory extends RequestFactory | ||||||
|             'lastname' => 'Muster', |             'lastname' => 'Muster', | ||||||
|             'letter_address' => '', |             'letter_address' => '', | ||||||
|             'location' => 'Solingen', |             'location' => 'Solingen', | ||||||
|             'main_phone' => '+49 212 337056', |             'main_phone' => '+49 212 2334322', | ||||||
|             'mobile_phone' => '+49 176 70512774', |             'mobile_phone' => '+49 157 53180451', | ||||||
|             'more_ps_at' => '', |             'more_ps_at' => '', | ||||||
|             'multiply_more_pv' => false, |             'multiply_more_pv' => false, | ||||||
|             'multiply_pv' => false, |             'multiply_pv' => false, | ||||||
|  | @ -47,13 +40,6 @@ class MemberRequestFactory extends RequestFactory | ||||||
|             'without_efz_at' => '', |             'without_efz_at' => '', | ||||||
|             'work_phone' => '', |             'work_phone' => '', | ||||||
|             'zip' => '42719', |             'zip' => '42719', | ||||||
|             'bank_account' => [ |  | ||||||
|                 'iban' => '', |  | ||||||
|                 'bic' => '', |  | ||||||
|             ], |  | ||||||
|             'country_id' => $country->id, |  | ||||||
|             'nationality_id' => $nationality->id, |  | ||||||
|             'subscription_id' => $subscription->id, |  | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -3,17 +3,58 @@ | ||||||
| namespace Tests\RequestFactories; | namespace Tests\RequestFactories; | ||||||
| 
 | 
 | ||||||
| use App\Activity; | use App\Activity; | ||||||
|  | use App\Country; | ||||||
|  | use App\Nationality; | ||||||
|  | use App\Payment\Subscription; | ||||||
| use App\Subactivity; | use App\Subactivity; | ||||||
|  | use Worksome\RequestFactories\RequestFactory; | ||||||
| 
 | 
 | ||||||
| class MemberStoreRequestFactory extends MemberRequestFactory | class MemberStoreRequestFactory extends RequestFactory | ||||||
| { | { | ||||||
|     public function definition(): array |     public function definition(): array | ||||||
|     { |     { | ||||||
|  |         $country = Country::factory()->create(); | ||||||
|  |         $nationality = Nationality::factory()->create(); | ||||||
|  |         $subscription = Subscription::factory()->forFee()->create(); | ||||||
|         $activity = Activity::factory()->inNami(89)->create(); |         $activity = Activity::factory()->inNami(89)->create(); | ||||||
|         $subactivity = Subactivity::factory()->inNami(90)->create(); |         $subactivity = Subactivity::factory()->inNami(90)->create(); | ||||||
| 
 | 
 | ||||||
|         return [ |         return [ | ||||||
|             ...parent::definition(), |             'bank_account' => [ | ||||||
|  |                 'iban' => '', | ||||||
|  |                 'bic' => '', | ||||||
|  |             ], | ||||||
|  |             'address' => 'Bavert 50', | ||||||
|  |             'birthday' => '2013-02-19', | ||||||
|  |             'children_phone' => '+49 176 70512778', | ||||||
|  |             'efz' => '', | ||||||
|  |             'email' => '', | ||||||
|  |             'email_parents' => 'osloot@aol.com', | ||||||
|  |             'fax' => '+49 212 4732223', | ||||||
|  |             'firstname' => 'Joe', | ||||||
|  |             'further_address' => '', | ||||||
|  |             'has_nami' => true, | ||||||
|  |             'has_svk' => false, | ||||||
|  |             'has_vk' => false, | ||||||
|  |             'joined_at' => '2022-08-12', | ||||||
|  |             'lastname' => 'Muster', | ||||||
|  |             'letter_address' => '', | ||||||
|  |             'location' => 'Solingen', | ||||||
|  |             'main_phone' => '+49 212 337056', | ||||||
|  |             'mobile_phone' => '+49 176 70512774', | ||||||
|  |             'more_ps_at' => '', | ||||||
|  |             'multiply_more_pv' => false, | ||||||
|  |             'multiply_pv' => false, | ||||||
|  |             'other_country' => '', | ||||||
|  |             'ps_at' => '', | ||||||
|  |             'send_newspaper' => true, | ||||||
|  |             'without_education_at' => '', | ||||||
|  |             'without_efz_at' => '', | ||||||
|  |             'work_phone' => '', | ||||||
|  |             'zip' => '42719', | ||||||
|  |             'country_id' => $country->id, | ||||||
|  |             'nationality_id' => $nationality->id, | ||||||
|  |             'subscription_id' => $subscription->id, | ||||||
|             'first_activity_id' => $activity->id, |             'first_activity_id' => $activity->id, | ||||||
|             'first_subactivity_id' => $subactivity->id, |             'first_subactivity_id' => $subactivity->id, | ||||||
|         ]; |         ]; | ||||||
|  |  | ||||||
|  | @ -1,11 +0,0 @@ | ||||||
| <?php |  | ||||||
| 
 |  | ||||||
| namespace Tests\RequestFactories; |  | ||||||
| 
 |  | ||||||
| class MemberUpdateRequestFactory extends MemberRequestFactory |  | ||||||
| { |  | ||||||
|     public function noNami(): self |  | ||||||
|     { |  | ||||||
|         return $this->state(['has_nami' => false]); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
		Loading…
	
		Reference in New Issue