Add tests for baustein

This commit is contained in:
philipp lang 2022-03-04 02:01:00 +01:00
parent 0816f1ad65
commit 07e5a9021c
2 changed files with 20 additions and 0 deletions

View File

@ -24,4 +24,15 @@ class BausteinFake extends Fake {
return $this; return $this;
} }
public function failsToFetch(): self
{
Http::fake(function($request) {
if ($request->url() === "https://nami.dpsg.de/ica/rest/module/baustein") {
return $this->errorResponse('error');
}
});
return $this;
}
} }

View File

@ -35,4 +35,13 @@ class BausteinTest extends TestCase
$this->assertEquals('abc', $courses->first()->name); $this->assertEquals('abc', $courses->first()->name);
} }
public function test_throw_exception_when_baustein_fetching_fails(): void
{
$this->expectException(NamiException::class);
Auth::success(12345, 'secret');
app(BausteinFake::class)->failsToFetch();
Nami::login(12345, 'secret')->courses();
}
} }