Compare commits

...

2 Commits

Author SHA1 Message Date
philipp lang 84103d4052 Lint 2024-06-29 11:17:10 +02:00
philipp lang 81670b900d Lint 2024-06-29 10:38:30 +02:00
1 changed files with 11 additions and 9 deletions

View File

@ -9,7 +9,7 @@ class GroupFake extends Fake
/** /**
* @param array<int, array{name: string}> $data * @param array<int, array{name: string}> $data
*/ */
public function fetches(?int $parent = null, array $data): self public function fetches(?int $parent, array $data): self
{ {
$this->fakeResponse($parent, $data); $this->fakeResponse($parent, $data);
@ -18,7 +18,7 @@ class GroupFake extends Fake
public function failsToFetch(int $parentId = null, ?string $error = 'wrong message'): void public function failsToFetch(int $parentId = null, ?string $error = 'wrong message'): void
{ {
$url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentId ?: 'root'); $url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/' . ($parentId ?: 'root');
Http::fake(function ($request) use ($url, $error) { Http::fake(function ($request) use ($url, $error) {
if ($request->url() === $url) { if ($request->url() === $url) {
return $this->errorResponse($error); return $this->errorResponse($error);
@ -28,7 +28,7 @@ class GroupFake extends Fake
public function failsToFetchWithoutJson(int $parentId = null, ?string $error = 'wrong message'): void public function failsToFetchWithoutJson(int $parentId = null, ?string $error = 'wrong message'): void
{ {
$url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentId ?: 'root'); $url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/' . ($parentId ?: 'root');
Http::fake(function ($request) use ($url) { Http::fake(function ($request) use ($url) {
if ($request->url() === $url) { if ($request->url() === $url) {
return $this->htmlResponse(); return $this->htmlResponse();
@ -36,9 +36,9 @@ class GroupFake extends Fake
}); });
} }
private function fakeResponse(?int $parentId = null, array $data): void private function fakeResponse(?int $parentId, array $data): void
{ {
$url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentId ?: 'root'); $url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/' . ($parentId ?: 'root');
Http::fake(function ($request) use ($data, $url) { Http::fake(function ($request) use ($data, $url) {
if ($request->url() === $url) { if ($request->url() === $url) {
return Http::response(json_encode([ return Http::response(json_encode([
@ -52,14 +52,16 @@ class GroupFake extends Fake
public function assertRootFetched(): void public function assertRootFetched(): void
{ {
Http::assertSent(fn ($request) => 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' === $request->url() Http::assertSent(
fn ($request) => 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' === $request->url()
&& 'GET' === $request->method() && 'GET' === $request->method()
); );
} }
public function assertFetched(int $id): void public function assertFetched(int $id): void
{ {
Http::assertSent(fn ($request) => $request->url() === 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.$id Http::assertSent(
fn ($request) => $request->url() === 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/' . $id
&& 'GET' === $request->method() && 'GET' === $request->method()
); );
} }