Compare commits
	
		
			No commits in common. "ff34c230327001e16d2a941bac57dd2d578f1936" and "51c3a489eea78a10afd1b7dbe965f0acd16df33f" have entirely different histories.
		
	
	
		
			ff34c23032
			...
			51c3a489ee
		
	
		|  | @ -153,6 +153,7 @@ class Api | ||||||
|         if ($member->id) { |         if ($member->id) { | ||||||
|             $existing = $this->rawMember($member->groupId, $member->id); |             $existing = $this->rawMember($member->groupId, $member->id); | ||||||
|             $payload = array_merge($existing, $member->toNami()); |             $payload = array_merge($existing, $member->toNami()); | ||||||
|  |             $payload['kontoverbindung'] = json_encode(data_get($payload, 'kontoverbindung', [])); | ||||||
|             $url = $this->url . '/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $member->groupId . '/' . $member->id; |             $url = $this->url . '/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $member->groupId . '/' . $member->id; | ||||||
|             $response = $this->http()->put($url, $payload); |             $response = $this->http()->put($url, $payload); | ||||||
|             $this->assertOk($response, $url, 'Update failed'); |             $this->assertOk($response, $url, 'Update failed'); | ||||||
|  |  | ||||||
|  | @ -4,15 +4,14 @@ namespace Zoomyboy\LaravelNami\Data; | ||||||
| 
 | 
 | ||||||
| use Spatie\LaravelData\Data; | use Spatie\LaravelData\Data; | ||||||
| use Spatie\LaravelData\Attributes\MapInputName; | use Spatie\LaravelData\Attributes\MapInputName; | ||||||
| use Zoomyboy\LaravelNami\Tests\Factories\BankAccountRequestFactory; |  | ||||||
| 
 | 
 | ||||||
| class BankAccount extends Data | class BankAccount extends Data | ||||||
| { | { | ||||||
|     public function __construct( |     public function __construct( | ||||||
|         public ?int $id, |         public int $id, | ||||||
| 
 | 
 | ||||||
|         #[MapInputName('mitgliedsNummer')]
 |         #[MapInputName('mitgliedsNummer')]
 | ||||||
|         public ?int $memberId, |         public int $memberId, | ||||||
| 
 | 
 | ||||||
|         #[MapInputName('bankleitzahl')]
 |         #[MapInputName('bankleitzahl')]
 | ||||||
|         public ?string $blz = null, |         public ?string $blz = null, | ||||||
|  | @ -28,27 +27,4 @@ class BankAccount extends Data | ||||||
|         public ?int $conditionId = null, |         public ?int $conditionId = null, | ||||||
|     ) { |     ) { | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     public static function toFactory(): BankAccountRequestFactory |  | ||||||
|     { |  | ||||||
|         return BankAccountRequestFactory::new(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * @return array<string, mixed> |  | ||||||
|      */ |  | ||||||
|     public function toNami(?int $memberId = null): string |  | ||||||
|     { |  | ||||||
|         return json_encode([ |  | ||||||
|             'id' => $this->id ?: '', |  | ||||||
|             'zahlungsKonditionId' => $this->conditionId, |  | ||||||
|             'mitgliedsNummer' => $memberId !== null ? $memberId : $this->memberId, |  | ||||||
|             'institut' => $this->bankName ?: '', |  | ||||||
|             'kontoinhaber' => $this->person ?: '', |  | ||||||
|             'kontonummer' => $this->accountNumber ?: '', |  | ||||||
|             'bankleitzahl' => $this->blz ?: '', |  | ||||||
|             'iban' => $this->iban ?: '', |  | ||||||
|             'bic' => $this->bic ?: '', |  | ||||||
|         ]); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -159,7 +159,6 @@ class Member extends Data | ||||||
|             'nameZusatz' => $this->furtherAddress, |             'nameZusatz' => $this->furtherAddress, | ||||||
|             'version' => $this->version, |             'version' => $this->version, | ||||||
|             'eintrittsdatum' => $this->joinedAt->format('Y-m-d 00:00:00'), |             'eintrittsdatum' => $this->joinedAt->format('Y-m-d 00:00:00'), | ||||||
|             'kontoverbindung' => $this->bankAccount->toNami($this->memberId), |  | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,27 +0,0 @@ | ||||||
| <?php |  | ||||||
| 
 |  | ||||||
| namespace Zoomyboy\LaravelNami\Tests\Factories; |  | ||||||
| 
 |  | ||||||
| use Worksome\RequestFactories\RequestFactory; |  | ||||||
| 
 |  | ||||||
| class BankAccountRequestFactory extends RequestFactory |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * @return array<string, mixed> |  | ||||||
|      */ |  | ||||||
|     public function definition(): array |  | ||||||
|     { |  | ||||||
|         return [ |  | ||||||
|             'id' => $this->faker->numberBetween(500, 1000), |  | ||||||
|             'memberId' => $this->faker->numberBetween(500, 1000), |  | ||||||
|         ]; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function empty(): self |  | ||||||
|     { |  | ||||||
|         return $this->state([ |  | ||||||
|             'id' => null, |  | ||||||
|             'memberId' => null, |  | ||||||
|         ]); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  | @ -35,11 +35,6 @@ class MemberRequestFactory extends RequestFactory | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function withBankAccount(BankAccountRequestFactory $bankAccount): self |  | ||||||
|     { |  | ||||||
|         return $this->state(['kontoverbindung' => $bankAccount->create()]); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function inNami(int $groupId, int $namiId): self |     public function inNami(int $groupId, int $namiId): self | ||||||
|     { |     { | ||||||
|         return $this->state([ |         return $this->state([ | ||||||
|  |  | ||||||
|  | @ -2,7 +2,6 @@ | ||||||
| 
 | 
 | ||||||
| namespace Zoomyboy\LaravelNami\Tests\Unit\Api; | namespace Zoomyboy\LaravelNami\Tests\Unit\Api; | ||||||
| 
 | 
 | ||||||
| use Zoomyboy\LaravelNami\Data\BankAccount; |  | ||||||
| use Zoomyboy\LaravelNami\Data\Member; | use Zoomyboy\LaravelNami\Data\Member; | ||||||
| use Zoomyboy\LaravelNami\Fakes\MemberFake; | use Zoomyboy\LaravelNami\Fakes\MemberFake; | ||||||
| use Zoomyboy\LaravelNami\Tests\TestCase; | use Zoomyboy\LaravelNami\Tests\TestCase; | ||||||
|  | @ -75,100 +74,6 @@ class PutMemberTest extends TestCase | ||||||
|         ]); |         ]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function testItPutsEmptyKontoverbindung(): void |  | ||||||
|     { |  | ||||||
|         app(MemberFake::class)->stores(103, 16); |  | ||||||
|         $member = Member::toFactory() |  | ||||||
|             ->withBankAccount(BankAccount::toFactory()->empty()) |  | ||||||
|             ->toMember(['groupId' => 103]); |  | ||||||
|         $response = $this->login()->putMember($member, 78, 79); |  | ||||||
| 
 |  | ||||||
|         $this->assertEquals(16, $response); |  | ||||||
| 
 |  | ||||||
|         app(MemberFake::class)->assertStored(103, [ |  | ||||||
|             'kontoverbindung' => json_encode([ |  | ||||||
|                 'id' => '', |  | ||||||
|                 'zahlungsKonditionId' => null, |  | ||||||
|                 'mitgliedsNummer' => null, |  | ||||||
|                 'institut' => '', |  | ||||||
|                 'kontoinhaber' => '', |  | ||||||
|                 'kontonummer' => '', |  | ||||||
|                 'bankleitzahl' => '', |  | ||||||
|                 'iban' => '', |  | ||||||
|                 'bic' => '', |  | ||||||
|             ]), |  | ||||||
|         ]); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function testItPutsFilledKontoverbindung(): void |  | ||||||
|     { |  | ||||||
|         app(MemberFake::class)->stores(103, 16); |  | ||||||
|         $member = Member::toFactory() |  | ||||||
|             ->withBankAccount(BankAccount::toFactory()->empty()->state([ |  | ||||||
|                 'zahlungsKonditionId' => 1, |  | ||||||
|                 'institut' => 'institut', |  | ||||||
|                 'kontoinhaber' => 'kontoinhaber', |  | ||||||
|                 'kontonummer' => 'kontonummer', |  | ||||||
|                 'bankleitzahl' => 'bankleitzahl', |  | ||||||
|                 'iban' => 'iban', |  | ||||||
|                 'bic' => 'bic', |  | ||||||
|             ])) |  | ||||||
|             ->toMember(['groupId' => 103]); |  | ||||||
|         $response = $this->login()->putMember($member, 78, 79); |  | ||||||
| 
 |  | ||||||
|         $this->assertEquals(16, $response); |  | ||||||
| 
 |  | ||||||
|         app(MemberFake::class)->assertStored(103, [ |  | ||||||
|             'kontoverbindung' => json_encode([ |  | ||||||
|                 'id' => '', |  | ||||||
|                 'zahlungsKonditionId' => 1, |  | ||||||
|                 'mitgliedsNummer' => null, |  | ||||||
|                 'institut' => 'institut', |  | ||||||
|                 'kontoinhaber' => 'kontoinhaber', |  | ||||||
|                 'kontonummer' => 'kontonummer', |  | ||||||
|                 'bankleitzahl' => 'bankleitzahl', |  | ||||||
|                 'iban' => 'iban', |  | ||||||
|                 'bic' => 'bic', |  | ||||||
|             ]), |  | ||||||
|         ]); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function testItUpdatesKontoverbindung(): void |  | ||||||
|     { |  | ||||||
|         app(MemberFake::class) |  | ||||||
|             ->updatesSuccessfully(103, 16) |  | ||||||
|             ->shows(103, 16); |  | ||||||
|         $member = Member::toFactory() |  | ||||||
|             ->withBankAccount(BankAccount::toFactory()->state([ |  | ||||||
|                 'id' => 555, |  | ||||||
|                 'zahlungsKonditionId' => 1, |  | ||||||
|                 'institut' => 'institut', |  | ||||||
|                 'kontoinhaber' => 'kontoinhaber', |  | ||||||
|                 'kontonummer' => 'kontonummer', |  | ||||||
|                 'bankleitzahl' => 'bankleitzahl', |  | ||||||
|                 'iban' => 'iban', |  | ||||||
|                 'bic' => 'bic', |  | ||||||
|             ])) |  | ||||||
|             ->toMember(['groupId' => 103, 'id' => 16, 'mitgliedsNummer' => 18]); |  | ||||||
|         $response = $this->login()->putMember($member); |  | ||||||
| 
 |  | ||||||
|         $this->assertEquals(16, $response); |  | ||||||
| 
 |  | ||||||
|         app(MemberFake::class)->assertUpdated(103, 16, [ |  | ||||||
|             'kontoverbindung' => json_encode([ |  | ||||||
|                 'id' => 555, |  | ||||||
|                 'zahlungsKonditionId' => 1, |  | ||||||
|                 'mitgliedsNummer' => 18, |  | ||||||
|                 'institut' => 'institut', |  | ||||||
|                 'kontoinhaber' => 'kontoinhaber', |  | ||||||
|                 'kontonummer' => 'kontonummer', |  | ||||||
|                 'bankleitzahl' => 'bankleitzahl', |  | ||||||
|                 'iban' => 'iban', |  | ||||||
|                 'bic' => 'bic', |  | ||||||
|             ]), |  | ||||||
|         ]); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public function testUpdateAMemberWithForeignAttributes(): void |     public function testUpdateAMemberWithForeignAttributes(): void | ||||||
|     { |     { | ||||||
|         app(MemberFake::class) |         app(MemberFake::class) | ||||||
|  | @ -232,6 +137,24 @@ class PutMemberTest extends TestCase | ||||||
|         ]); |         ]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function testItMergesKontoverbindung(): void | ||||||
|  |     { | ||||||
|  |         app(MemberFake::class) | ||||||
|  |             ->updatesSuccessfully(103, 16) | ||||||
|  |             ->shows(103, 16, [ | ||||||
|  |                 'foreign' => 'fff', | ||||||
|  |                 'kontoverbindung' => ['a' => 'b'], | ||||||
|  |             ]); | ||||||
|  |         $response = $this->login()->putMember(Member::toFactory()->inNami(103, 16)->toMember()); | ||||||
|  | 
 | ||||||
|  |         $this->assertEquals(16, $response); | ||||||
|  | 
 | ||||||
|  |         app(MemberFake::class)->assertUpdated(103, 16, [ | ||||||
|  |             'kontoverbindung' => '{"a":"b"}', | ||||||
|  |             'foreign' => 'fff', | ||||||
|  |         ]); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function testUpdateToDefaultGenderIdAndRegionIdIfTheyAreNull(): void |     public function testUpdateToDefaultGenderIdAndRegionIdIfTheyAreNull(): void | ||||||
|     { |     { | ||||||
|         app(MemberFake::class) |         app(MemberFake::class) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue