Throw exception when update failed
This commit is contained in:
parent
b7649f9607
commit
78860cb529
|
@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Zoomyboy\LaravelNami\Backend\Backend;
|
use Zoomyboy\LaravelNami\Backend\Backend;
|
||||||
use Zoomyboy\LaravelNami\Concerns\IsNamiMember;
|
use Zoomyboy\LaravelNami\Concerns\IsNamiMember;
|
||||||
|
use Zoomyboy\LaravelNami\NamiException;
|
||||||
|
|
||||||
class Api {
|
class Api {
|
||||||
|
|
||||||
|
@ -67,7 +68,11 @@ class Api {
|
||||||
|
|
||||||
public function putMember(array $attributes) {
|
public function putMember(array $attributes) {
|
||||||
$member = Member::fromAttributes($attributes);
|
$member = Member::fromAttributes($attributes);
|
||||||
$this->http()->put(self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->group_id.'/'.$member->id, $member->toNami());
|
$response = $this->http()->put(self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->group_id.'/'.$member->id, $member->toNami());
|
||||||
|
|
||||||
|
if (!data_get($response->json(), 'id')) {
|
||||||
|
throw new NamiException('update failed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function membershipsOf($memberId): Collection {
|
public function membershipsOf($memberId): Collection {
|
||||||
|
|
|
@ -70,8 +70,8 @@ class PushMemberTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function test_push_a_single_member($key, $values) {
|
public function test_push_a_single_member($key, $values) {
|
||||||
Http::fake(array_merge($this->login(), [
|
Http::fake(array_merge($this->login(), [
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response('', 200),
|
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response('{"id": 16}', 200),
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/17' => Http::response('', 200),
|
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/17' => Http::response('{"id": 17}', 200),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$this->setCredentials();
|
$this->setCredentials();
|
||||||
|
|
Loading…
Reference in New Issue