Below you will find pages that utilize the taxonomy term “Assertion”
Articles
read more
PHPUnit: Writing a Custom Assertion
When you see yourself repeating a number of assertions in your unit tests, or you have to think hard each time you make some kind of assertion, it’s time to create your own assertions, which wraps these complicated assertions into one single method call on your TestCase
class. In the example below, I will create a custom assertion which would recognize the following JSON string as a “successful response”:
{"success":true}
Inside a TestCase
we could run the following lines of code to verify the successfulness of the given JSON response string: