Tutorial by Examples

Introduction The PHPUnit Manual describes mocking as such: The practice of replacing an object with a test double that verifies expectations, for instance asserting that a method has been called, is referred to as mocking. So instead of stubbing out code, an observer is created that not onl...
Sometimes there are sections of code that are difficult to test, such as accessing a database, or interacting with the user. You can stub out those sections of code, allowing the rest of the code to be tested. Let's start with a class that prompts the user. For simplicity, it has only two methods...

Page 1 of 1