Add deleted member to memberFake

This commit is contained in:
Philipp Lang 2022-09-05 11:37:15 +02:00
parent 6676b91cda
commit 5ce86d632d
1 changed files with 51 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace Zoomyboy\LaravelNami\Fakes;
use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
class MemberFake extends Fake
@ -26,4 +27,54 @@ class MemberFake extends Fake
}
});
}
public function deletes(int $memberId, Carbon $date): void
{
Http::fake(function ($request) use ($memberId, $date) {
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/mglschaft-beenden';
if ($request->url() !== $url || 'POST' !== $request->method()) {
return null;
}
if ((int) data_get($request, 'id') !== $memberId) {
return;
}
if ('true' !== data_get($request, 'isConfirmed')) {
return;
}
if (Carbon::parse(data_get($request, 'beendenZumDatum'))->format('Y-m-d') !== $date->format('Y-m-d')) {
return;
}
return $this->nullResponse();
});
}
public function assertDeleted(int $memberId, Carbon $date): void
{
Http::assertSent(function ($request) use ($memberId, $date) {
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/mglschaft-beenden';
if ($request->url() !== $url || 'POST' !== $request->method()) {
return false;
}
if ((int) data_get($request, 'id') !== $memberId) {
return false;
}
if ('true' !== data_get($request, 'isConfirmed')) {
return false;
}
if (Carbon::parse(data_get($request, 'beendenZumDatum'))->format('Y-m-d') !== $date->format('Y-m-d')) {
return false;
}
return true;
});
}
}