Reputation: 306
$response = $this->call('GET','abc?foo=bar');
I'm unable to get PHPUnit to transmit foo
as a request variable. Any thoughts? Am I missing something?
Upvotes: 3
Views: 2782
Reputation: 306
thx, @dov-benyomin-sohacheski. the call() method seemed to be limited in the manner in which it renders the url response. i believe it's a php cli command and not transmitting over the wire. even when using an associative array i could not get it to recognize query parameters. post data was no problem, but i needed to emulate GET calls.
the solution for me proved to be using Guzzle as a http client. they have a query string parameters spec.
i'm new to testing so learning a lot quickly...feel free to correct me if i missed something.
Upvotes: 0
Reputation: 7732
Your issue is not a PHPUnit issue, it is a Laravel one.
The call()
method has the following signature:
call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null);
You should send the query string as an associative array.
If you want to directly test a controller, you should use the action()
method, which has the following signature:
action($method, $action, $wildcards = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
Upvotes: 4