Fixed: Delete Course
This commit is contained in:
parent
64ce14910a
commit
d348aea5f6
11
src/Api.php
11
src/Api.php
|
@ -260,7 +260,16 @@ class Api {
|
|||
]);
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
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';
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue