Mod member fake

This commit is contained in:
philipp lang 2024-03-09 00:13:01 +01:00
parent dfd3fbb6ee
commit b8164cd3d2
2 changed files with 7 additions and 7 deletions

View File

@ -10,7 +10,7 @@ class MemberFake extends Fake
public function fetchFails(int $groupId, int $memberId, string $error = 'wrong message'): void
{
Http::fake(function ($request) use ($groupId, $memberId, $error) {
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $groupId . '/' . $memberId;
if ($request->url() === $url && 'GET' === $request->method()) {
return $this->errorResponse($error);
}
@ -23,7 +23,7 @@ class MemberFake extends Fake
public function shows(int $groupId, int $memberId, array $data = []): self
{
Http::fake(function ($request) use ($groupId, $memberId, $data) {
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $groupId . '/' . $memberId;
if ($request->url() === $url && 'GET' === $request->method()) {
return $this->dataResponse(array_merge([
'beitragsartId' => 1,
@ -94,7 +94,7 @@ class MemberFake extends Fake
public function updatesSuccessfully(int $groupId, int $memberId, array $data = []): self
{
Http::fake(function ($request) use ($groupId, $memberId, $data) {
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/' . $groupId . '/' . $memberId;
if ($request->url() === $url && 'PUT' === $request->method()) {
return $this->dataResponse([
'id' => $memberId,
@ -106,7 +106,7 @@ class MemberFake extends Fake
return $this;
}
public function createsSuccessfully(int $groupId, int $memberId): self
public function stores(int $groupId, int $memberId): self
{
Http::fake(function ($request) use ($memberId, $groupId) {
$url = "https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/{$groupId}";
@ -122,7 +122,7 @@ class MemberFake extends Fake
/**
* @param array<string, string|int|bool|null> $body
*/
public function assertCreated(int $groupId, array $body): void
public function assertStored(int $groupId, array $body): void
{
Http::assertSent(function ($request) use ($groupId, $body) {
$url = "https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/{$groupId}";

View File

@ -10,7 +10,7 @@ class PutMemberTest extends TestCase
{
public function testPushASingleMember(): void
{
app(MemberFake::class)->createsSuccessfully(103, 16);
app(MemberFake::class)->stores(103, 16);
$member = Member::factory()->toMember([
'firstname' => 'Max',
'lastname' => 'Nach1',
@ -43,7 +43,7 @@ class PutMemberTest extends TestCase
$this->assertEquals(16, $response);
app(MemberFake::class)->assertCreated(103, [
app(MemberFake::class)->assertStored(103, [
'spitzname' => 'spitz1',
'vorname' => 'Max',
'nachname' => 'Nach1',