You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose we have an action that receives it's concrete Request as parameter at it's run() method, and that it uses the Requests's sanitizeInput() on an URL parameter. In this situation, the parameter returned will be null, and not the value given to it.
Steps To Reproduce
Assume the following code:
// SomeAction.phpclass SomeAction extends Action
{
// Notice that the argument is the SomeRequest concrete class, and not the Request parentpublicfunctionrun(SomeRequest$request)
{
$data = $request->sanitizeInput(['some-url-param']);
return$data['some-url-param']); // will be null during unit testing
}
}
// SomeRequest.phpclass SomeRequest extends Request {
protected$urlParameters = ['some-url-param'];
}
// SomeActionTest.phpclass SomeActionTest extends UnitTestCase
{
publicfunctiontestShouldSanitizeUrlParam()
{
$request = SomeRequest::injectData()->withUrlParameters(['some-url-param' => 123]);
$result = app(SomeAction::class)->run($request);
$this->assertEquals(123, $result); // this will fail
}
}
mergeUrlParametersWithRequestData() (same file), which in turn calls
route() (Illuminate\Http\Request).
route() will return null whenever the Request's getRouteResolver() fail to find an route, which is the case here (SomeRequest was manually instantiated).
FakeRequest does not declare any URL parameters, and so sanitizeInput() will play along with it.
The text was updated successfully, but these errors were encountered:
Apiato Core Version
8.x
PHP Version
8.1.x
Database Driver & Version
No response
Description
Suppose we have an action that receives it's concrete Request as parameter at it's
run()
method, and that it uses the Requests'ssanitizeInput()
on an URL parameter. In this situation, the parameter returned will be null, and not the value given to it.Steps To Reproduce
Assume the following code:
@Mohammad-Alavi and I follwed the trail, and we found that
sanitizeInput()
(Apiato\Core\Abstracts\Requests\Request
) callsmergeUrlParametersWithRequestData()
(same file), which in turn callsroute()
(Illuminate\Http\Request
).route()
will returnnull
whenever the Request'sgetRouteResolver()
fail to find an route, which is the case here (SomeRequest
was manually instantiated).FakeRequest
does not declare any URL parameters, and sosanitizeInput()
will play along with it.The text was updated successfully, but these errors were encountered: