Fixed: Dont abort when subactivities return html
This commit is contained in:
parent
423fb27f51
commit
899264db51
|
@ -174,7 +174,11 @@ class Api {
|
||||||
$url = $this->url.'/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/'.$activityId;
|
$url = $this->url.'/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/'.$activityId;
|
||||||
$response = $this->http()->get($url);
|
$response = $this->http()->get($url);
|
||||||
|
|
||||||
if ($response['success'] === false) {
|
if ($response->json() === null) {
|
||||||
|
return collect([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data_get($response, 'success') === false) {
|
||||||
$this->exception('Getting subactivities failed', $url, $response->json());
|
$this->exception('Getting subactivities failed', $url, $response->json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,9 @@ abstract class Fake {
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function htmlResponse(): PromiseInterface
|
||||||
|
{
|
||||||
|
return Http::response('<html></html>');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,13 @@ class SubactivityFake extends Fake {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fetchFailsWithoutJson(int $activityId): void
|
||||||
|
{
|
||||||
|
Http::fake(function($request) use ($activityId) {
|
||||||
|
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/'.$activityId) {
|
||||||
|
return $this->htmlResponse();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,17 +54,17 @@ class PullActivitiesTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->expectException(NamiException::class);
|
$this->expectException(NamiException::class);
|
||||||
app(SubactivityFake::class)->fetchFails(4, 'sorry dude');
|
app(SubactivityFake::class)->fetchFails(4, 'sorry dude');
|
||||||
Http::fake([
|
|
||||||
'https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/4' => Http::response($this->fakeJson('subactivities-4.json'), 200)
|
$subactivities = $this->login()->subactivitiesOf(4);
|
||||||
]);
|
}
|
||||||
|
|
||||||
|
public function test_continue_if_subactivities_request_returns_html(): void
|
||||||
|
{
|
||||||
|
app(SubactivityFake::class)->fetchFailsWithoutJson(4);
|
||||||
|
|
||||||
$subactivities = $this->login()->subactivitiesOf(4);
|
$subactivities = $this->login()->subactivitiesOf(4);
|
||||||
|
|
||||||
$this->assertSame([
|
$this->assertCount(0, $subactivities);
|
||||||
[ 'name' => 'Biber', 'id' => 40 ],
|
|
||||||
[ 'name' => 'Wölfling', 'id' => 30 ]
|
|
||||||
], $subactivities->toArray());
|
|
||||||
Http::assertSentCount(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue