Fixed: Delete Course

This commit is contained in:
philipp lang 2021-11-20 01:08:56 +01:00
parent 64ce14910a
commit d348aea5f6
2 changed files with 44 additions and 1 deletions

View File

@ -260,7 +260,16 @@ class Api {
]); ]);
if (data_get($response->json(), 'success') !== true) { if (data_get($response->json(), 'success') !== true) {
$this->exception('Course creation failed', $payload, $response->json()); $this->exception('Course update failed', $payload, $response->json());
}
}
public function deleteCourse(int $memberId, int $courseId): void
{
$response = $this->http()->delete(self::$url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}");
if (data_get($response->json(), 'success') !== true) {
$this->exception('Course deletion failed', [], $response->json());
} }
} }

View File

@ -33,6 +33,32 @@ class CourseFake extends Fake {
}); });
} }
public function deleteSuccessful(int $memberId, int $courseId): void
{
Http::fake(function($request) use ($memberId, $courseId) {
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'DELETE') {
return Http::response([
'data' => null,
'responseType' => 'OK',
'success' => true,
], 200);
}
});
}
public function deleteFailed(int $memberId, int $courseId): void
{
Http::fake(function($request) use ($memberId, $courseId) {
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'DELETE') {
return Http::response([
'data' => null,
'responseType' => 'NOK',
'success' => false,
], 200);
}
});
}
public function doesntCreateWithError(int $memberId): void public function doesntCreateWithError(int $memberId): void
{ {
Http::fake(function($request) use ($memberId) { Http::fake(function($request) use ($memberId) {
@ -84,4 +110,12 @@ class CourseFake extends Fake {
}); });
} }
public function assertDeleted(int $memberId, int $courseId): void
{
Http::assertSent(function($request) use ($memberId, $courseId) {
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/${courseId}"
&& $request->method() === 'DELETE';
});
}
} }