What is the full code for your test?
My immediate suspicion might be that for your test you are first signing in a user, which is why your dump of the Request object is showing 'GET'
I have a service provider which binds a service based on route parameter. Everything works nice but now I'm trying to test my controller, and for some reason request parameters are empty in my service provider :(
Service provider:
public function register()
{
$this->app->call([$this, 'registerServices']);
}
public function registerServices(Request $request)
{
dd($request); //here request params are empty
....
$this->app->bind...
}
Controller test - tried different methods but my request is always empty:
$response = $this->json('POST', $route, $params);
$response = $this->post($route, $params);
$this->call('POST', $route, $params);
And this is the output of request object
Illuminate\Http\Request {#17
#json: null
#convertedFiles: null
#userResolver: null
#routeResolver: null
+attributes: Symfony\Component\HttpFoundation\ParameterBag {#29
#parameters: []
}
+request: Symfony\Component\HttpFoundation\ParameterBag {#370
#parameters: []
}
+query: Symfony\Component\HttpFoundation\ParameterBag {#30
#parameters: []
}
+server: Symfony\Component\HttpFoundation\ServerBag {#36
...
pathInfo: "/"
requestUri: "/"
baseUrl: ""
basePath: ""
method: "GET"
format: "html"
Am I doing something wrong here? Why are request params empty here? Also I'm doing a post request and in my dump of request object there is a get method. Whats the reason for this?
Please or to participate in this conversation.