From the course: PHP: Testing Legacy Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Quick primer on test doubles

Quick primer on test doubles

From the course: PHP: Testing Legacy Applications

Start my 1-month free trial

Quick primer on test doubles

- [Instructor] Understanding where test doubles fit into my tests, was one of the biggest hurdles I had to overcome when first learning TDD. They are powerful but easily misused. I want to go over the different types of test doubles you will find in your tests. So what is a double? Simply put, a double is a substitute for a real dependency the code you are testing needs. Most testing frameworks that use assertion based tests either provide you with the tools or they're available as a library or extension. PHPUnit comes with Prophecy installed, which is a great tool for creating test doubles. I prefer to use Mockery, I like the syntax better then Prophecy. As a quick aside, most people who use these tools refer to them as mocks. Mocks are simply just a type of test double but the original methods inside PHPUnit for creating doubles were called getMock and getMockBuilder. Mocks could be thought of, and I'm using air quotes here, the brand name for doubles, but mocks are just another…

Contents