From 71d4c2446b532a3ce3ee4b1146a58e1c7f853b7d Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 16 Nov 2022 01:33:54 +0100 Subject: [PATCH] Add activity fake --- src/Fakes/ActivityFake.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Fakes/ActivityFake.php diff --git a/src/Fakes/ActivityFake.php b/src/Fakes/ActivityFake.php new file mode 100644 index 0000000..d5f5639 --- /dev/null +++ b/src/Fakes/ActivityFake.php @@ -0,0 +1,38 @@ + $data + */ + public function fetches(int $groupId, array $data): self + { + Http::fake(function ($request) use ($data, $groupId) { + $url = "https://nami.dpsg.de/ica/rest/nami/taetigkeitaufgruppierung/filtered/gruppierung/gruppierung/{$groupId}"; + if ($request->url() === $url && 'GET' === $request->method()) { + return $this->dataResponse($data); + } + }); + + return $this; + } + + /** + * @param array $data + */ + public function fetchesSubactivity(int $activityId, array $data): self + { + Http::fake(function ($request) use ($data, $activityId) { + $url = "https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/{$activityId}"; + if ($request->url() === $url && 'GET' === $request->method()) { + return $this->dataResponse($data); + } + }); + + return $this; + } +}