From 7cdf3903647b79d396d945c2062bef4f907a6fe7 Mon Sep 17 00:00:00 2001 From: shalvah Date: Wed, 14 Dec 2022 19:45:40 +0100 Subject: [PATCH] Fix tests --- src/Extracting/Strategies/GetFromFormRequestBase.php | 2 +- tests/Strategies/GetFromFormRequestTest.php | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Extracting/Strategies/GetFromFormRequestBase.php b/src/Extracting/Strategies/GetFromFormRequestBase.php index 75f6a1bf..86defe32 100644 --- a/src/Extracting/Strategies/GetFromFormRequestBase.php +++ b/src/Extracting/Strategies/GetFromFormRequestBase.php @@ -25,7 +25,7 @@ public function __invoke(ExtractedEndpointData $endpointData, array $routeRules return $this->getParametersFromFormRequest($endpointData->method, $endpointData->route); } - public function getParametersFromFormRequest(ReflectionFunctionAbstract $method, ?Route $route = null): array + public function getParametersFromFormRequest(ReflectionFunctionAbstract $method, Route $route): array { if (!$formRequestReflectionClass = $this->getFormRequestReflectionClass($method)) { return []; diff --git a/tests/Strategies/GetFromFormRequestTest.php b/tests/Strategies/GetFromFormRequestTest.php index 2ff3f190..22180eb1 100644 --- a/tests/Strategies/GetFromFormRequestTest.php +++ b/tests/Strategies/GetFromFormRequestTest.php @@ -2,6 +2,7 @@ namespace Knuckles\Scribe\Tests\Strategies; +use Illuminate\Routing\Route; use Knuckles\Scribe\Extracting\Strategies\BodyParameters; use Knuckles\Scribe\Extracting\Strategies\QueryParameters; use Knuckles\Scribe\Tests\BaseLaravelTest; @@ -228,9 +229,8 @@ public function allows_customisation_of_form_request_instantiation() { $controllerMethod = new \ReflectionMethod(TestController::class, 'withFormRequestParameter'); - Globals::$__instantiateFormRequestUsing = function ($className, $route, $method) use (&$controllerMethod) { + Globals::$__instantiateFormRequestUsing = function (string $className, Route $route, string $method) use (&$controllerMethod) { Assert::assertEquals(TestRequest::class, $className); - Assert::assertEquals(null, $route); Assert::assertEquals($controllerMethod, $method); return new TestRequestQueryParams; }; @@ -243,12 +243,14 @@ public function allows_customisation_of_form_request_instantiation() protected function fetchViaBodyParams(\ReflectionMethod $method): array { $strategy = new BodyParameters\GetFromFormRequest(new DocumentationConfig([])); - return $strategy->getParametersFromFormRequest($method); + $route = new Route(['POST'], "/test", ['uses' => [TestController::class, 'dummy']]); + return $strategy->getParametersFromFormRequest($method, $route); } protected function fetchViaQueryParams(\ReflectionMethod $method): array { $strategy = new QueryParameters\GetFromFormRequest(new DocumentationConfig([])); - return $strategy->getParametersFromFormRequest($method); + $route = new Route(['POST'], "/test", ['uses' => [TestController::class, 'dummy']]); + return $strategy->getParametersFromFormRequest($method, $route); } }