Add tests for baustein
This commit is contained in:
parent
0816f1ad65
commit
07e5a9021c
|
@ -24,4 +24,15 @@ class BausteinFake extends Fake {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,4 +35,13 @@ class BausteinTest extends TestCase
|
|||
$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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue