From 32a451fb3537669269baf5f80bbb5cda97337333 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 2 Jan 2022 21:49:57 +0100 Subject: [PATCH] Fake memberships --- src/Backend/FakeBackend.php | 18 ++++++++++++++++++ tests/Unit/PullMembershipsTest.php | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Backend/FakeBackend.php b/src/Backend/FakeBackend.php index a0c5e83..5de555a 100644 --- a/src/Backend/FakeBackend.php +++ b/src/Backend/FakeBackend.php @@ -82,6 +82,24 @@ class FakeBackend { return Http::response(json_encode($content) ?: '{}', 200); } + + if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$member['id']}/flist") { + $content = [ + 'success' => true, + 'data' => array_map(function($membership) { + return (object) [ + 'entries_aktivVon' => $membership['aktivVon'], + 'entries_aktivBis' => $membership['aktivBis'], + 'entries_gruppierung' => $membership['gruppierung'], + 'id' => $membership['id'], + 'entries_taetigkeit' => $membership['taetigkeit'], + 'entries_untergliederung' => $membership['untergliederung'], + ]; + }, $member['memberships'] ?? []) + ]; + + return Http::response(json_encode($content) ?: '{}', 200); + } } foreach (collect($data)->chunk(100) as $i => $chunk) { diff --git a/tests/Unit/PullMembershipsTest.php b/tests/Unit/PullMembershipsTest.php index 9054023..4a8da94 100644 --- a/tests/Unit/PullMembershipsTest.php +++ b/tests/Unit/PullMembershipsTest.php @@ -2,10 +2,10 @@ namespace Zoomyboy\LaravelNami\Tests\Unit; -use Zoomyboy\LaravelNami\Nami; -use Zoomyboy\LaravelNami\Tests\TestCase; use Illuminate\Support\Facades\Http; use Zoomyboy\LaravelNami\Member; +use Zoomyboy\LaravelNami\Nami; +use Zoomyboy\LaravelNami\Tests\TestCase; class PullMembershipsTest extends TestCase {