From b4f19721626f37e4a5c6bc7d4998b8b7200cf1a9 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 5 Mar 2022 22:35:58 +0100 Subject: [PATCH] Fixed membership fake --- src/Api.php | 3 ++- src/Fakes/MemberFake.php | 12 ++++++++++++ src/Fakes/MembershipFake.php | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Api.php b/src/Api.php index 3a14b41..3604f9b 100644 --- a/src/Api.php +++ b/src/Api.php @@ -284,7 +284,8 @@ class Api { } } - public function member($groupId, $memberId) { + public function member(int $groupId, int $memberId): array + { $this->assertLoggedIn(); $url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId; $response = $this->http()->get($url); diff --git a/src/Fakes/MemberFake.php b/src/Fakes/MemberFake.php index 2f389dc..8909197 100644 --- a/src/Fakes/MemberFake.php +++ b/src/Fakes/MemberFake.php @@ -17,4 +17,16 @@ class MemberFake extends Fake { }); } + public function shows(int $groupId, int $memberId, array $data): void + { + Http::fake(function($request) use ($groupId, $memberId, $data) { + $url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId; + if ($request->url() === $url && $request->method() === 'GET') { + return $this->dataResponse(array_merge([ + + ], $data)); + } + }); + } + } diff --git a/src/Fakes/MembershipFake.php b/src/Fakes/MembershipFake.php index 1be9483..48677b4 100644 --- a/src/Fakes/MembershipFake.php +++ b/src/Fakes/MembershipFake.php @@ -124,9 +124,9 @@ class MembershipFake extends Fake { if ( data_get($request, 'gruppierungId') !== data_get($payload, 'gruppierungId') - && data_get($request, 'id') !== data_get($payload, 'id') - && data_get($request, 'taetigkeitId') !== data_get($payload, 'taetigkeitId') - && data_get($request, 'untergliederungId') !== data_get($payload, 'untergliederungId') + || data_get($request, 'id') !== data_get($payload, 'id') + || data_get($request, 'taetigkeitId') !== data_get($payload, 'taetigkeitId') + || data_get($request, 'untergliederungId') !== data_get($payload, 'untergliederungId') ) { return false; }