When we write a client to integrate an API in our systems it is important to test it to be sure we can handle every possible response. Guzzle client provides a very simple way to mock external APIs responses: Guzzle Mock Handler. This tool provides a mock handler that can be used to fulfill HTTP requests with a response or exception by shifting return values off of a queue.
Imagine you need to use a fixed numeric value in your code, let’s say 20000. It is what we call a literal constant, that is a value that will always remain the exact same in your code.
Now imagine you need to use that value more than once. Sooner or later you will read your code and you will not remember what 20000 was, it will happen for sure. But what if you assign the value to an immutable variable with a meaningful name? Let’s say something like this:
Everyone who works in software development has stumbled upon software testing.
The goal of this article is to define basic concepts related to testing, trying not to take anything for granted.
The 2020 edition of PHPDay took place on September 8th in a remote fashion.
Share this post
X
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email