Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Dec 14, 2022
1 parent a9e41c1 commit 7cdf390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Extracting/Strategies/GetFromFormRequestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
10 changes: 6 additions & 4 deletions tests/Strategies/GetFromFormRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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);
}
}

0 comments on commit 7cdf390

Please sign in to comment.