07.
Add a Test!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
8 Comments
I am getting the following error
GuzzleHttp\Exception\RequestException : cURL error 3: <url> malformed when configuring the test
Hey Miguel,
I bet you have bad URL for your request. What's it? Is it something relative like '/'? Try to use absolute URL. Does it fix you problem?
P.S. You can disable verification with:
$response = $client->get('https://api.github.com/', ['verify' => false]);, but better do not do this.Cheers!
base_uri, not base_url
Hey Alexandr,
Thank you for this tip! Yeah, in a newer version of Guzzle (newer than we use in this course) they renamed "base_url" -> "base_uri".
Cheers!
In my app I am using Doctrine Blameable Extension, so it sets the current user when creating a post on the createdBy field.
How can I handle this when running my tests?
Hey Shaun,
You probably need an integration test, but it depends on tools you use. I suppose you use PHPUnit, so take a look at functional tests: http://symfony.com/doc/curr... . You need to authenticate user, create a new post and then check that the post has the current user in createdBy field.
Cheers!
I was getting the error: "Failed to connect to localhost port 80:", even though I was specifying `http://localhost:8000`.
I resolved this by changing `base_url` to `base_uri` in the config of the GuzzleHttp Client constructor.
Also, echoing the response was not working. I had to `echo $response->getBody();`
I am running PHP 7.1 locally. Perhaps this or Guzzle changes since this video was produced are factors.
Hey Mike Milano
You are absolutely right, Guzzle has changed a bit since the tutorial was recorded. Thanks for informing us, we will add a note to the video to prevent other users from this "What a heck" moment
Cheers!
"Houston: no signs of life"
Start the conversation!