Using VCR for API testing
Alright, we are now making calls with Guzzle to a real API (see the section Using Tests to Think Through Your Code TDT (Test Driven Thinking) earlier in this chapter). But they are going to get pretty annoyed with us if we are hitting their API for all our tests. Also, it is going to slow down our tests. Right now, the speed difference is nominal since there is only one request, but once there are more, the time will really add up. So, to prevent this, we begin to use VCR to create fixtures of our HTTP requests and responses so that the next time we call them, they are delivered to us instead.
Getting ready
This one is a bit tricky on the installation. I will cover the installation in the upcoming steps, and then go into detail in the How it Works… section. Also, this is one of the recipes that I will be doing from inside Homestead, so begin with homestead ssh
into your box.
How to do it...
Install SOAP for PHP:
> sudo apt-get install php-soap
Then, we can go on...