Add failsCreating for membership fake

This commit is contained in:
philipp lang 2022-11-10 23:29:25 +01:00
parent c1e81b53f0
commit b1da07e828
1 changed files with 12 additions and 0 deletions

View File

@ -94,6 +94,18 @@ class MembershipFake extends Fake
return $this; return $this;
} }
public function failsCreating(int $memberId, ?string $error = 'Error'): self
{
Http::fake(function ($request) use ($memberId, $error) {
$url = "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
if ($request->url() === $url && 'POST' === $request->method()) {
return $this->errorResponse($error);
}
});
return $this;
}
public function failsShowingWithHtml(int $memberId, int $membershipId): self public function failsShowingWithHtml(int $memberId, int $membershipId): self
{ {
Http::fake(function ($request) use ($memberId, $membershipId) { Http::fake(function ($request) use ($memberId, $membershipId) {