diff --git a/composer.json b/composer.json index ced4c20..a874820 100755 --- a/composer.json +++ b/composer.json @@ -63,7 +63,10 @@ "config": { "optimize-autoloader": true, "sort-packages": true, - "secure-http": false + "secure-http": false, + "allow-plugins": { + "pestphp/pest-plugin": true + } }, "autoload": { "psr-4": { diff --git a/src/Service/ExtendService.php b/src/Service/ExtendService.php index 3c290f1..14a0938 100644 --- a/src/Service/ExtendService.php +++ b/src/Service/ExtendService.php @@ -19,7 +19,7 @@ class ExtendService ?ServerRequestInterface $request, ?array $params = null ): array { - $params ??= $request->getQueryParams(); + $params ??= $request?->getQueryParams(); $extends = $params['extends'] ?? null; if (!empty($extends)) { $extends = explode(',', $extends); diff --git a/tests/Unit/ExtendServiceTest.php b/tests/Unit/ExtendServiceTest.php index 22f9aad..0c37045 100644 --- a/tests/Unit/ExtendServiceTest.php +++ b/tests/Unit/ExtendServiceTest.php @@ -13,6 +13,15 @@ use Singularity\HDK\Core\Service\ExtendService; $service = new ExtendService(); +it('asserts no parameters can be parsed.', function () use ($service) { + $service->parse( + null, + null + ); + $result = $service->getExtends(); + expect($result)->toBeArray()->toHaveCount(0)->toBe([]); +})->only(); + it('asserts query parameters can be parsed.', function () use ($service) { $result = $service->parse( null,