3
$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?

1
  • It's rather not possible. It works without any problems. You haven't mentioned Laravel version of why do you think you don't have those data when reaching controller. Commented May 31, 2016 at 16:34

2 Answers 2

4

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)
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.