Revert "Add callable for fakes"
This commit is contained in:
parent
7189511a55
commit
f3c7fbed50
|
@ -56,29 +56,4 @@ abstract class Fake
|
|||
{
|
||||
return Http::response('<html></html>');
|
||||
}
|
||||
|
||||
public function assertBodyMatches(string $is, array|callable $should): bool
|
||||
{
|
||||
$requestBody = json_decode($is, true);
|
||||
|
||||
if (!is_array($requestBody)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_callable($should)) {
|
||||
return $should($requestBody);
|
||||
}
|
||||
|
||||
foreach ($should as $key => $value) {
|
||||
if (!array_key_exists($key, $requestBody)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($requestBody[$key] !== $value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ class MembershipFake extends Fake
|
|||
});
|
||||
}
|
||||
|
||||
public function assertCreated(int $memberId, array|callable $payload): void
|
||||
public function assertCreated(int $memberId, array $payload): void
|
||||
{
|
||||
$url = "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
|
||||
|
@ -195,3 +195,21 @@ class MembershipFake extends Fake
|
|||
|
||||
public function assertUpdated(int $memberId, array $payload): void
|
||||
{
|
||||
$url = "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/{$payload['id']}";
|
||||
Http::assertSent(function ($request) use ($url, $payload) {
|
||||
if ($request->url() !== $url || 'PUT' !== $request->method()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data_get($request, 'id') !== $payload['id']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data_get($request, 'aktivBis') !== data_get($payload, 'aktivBis')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue