The article continues the series of questions and answers about the problems of unit testing in PHP applications. In this part we’ll consider PHPUnit and mocking, such as disadvantages of the classical mocking framework and feature of its native alternative Prophecy, highlight common fallacies of how the test doubles should be used to make the object oriented design better.
This series of articles is an experimental attempt to explain problems of unit tests in PHP applications, turning the theory upside down. From my practice I know it well that even skilled developers often have difficulties with rearranging their OOP knowledge onto new test driven approach. I will try to share my experience with the subject in form of original questions and answers, that elucidate very important and not always obvious aspects of unit testing and clean code practices.
In the first part we’ll consider the common misunderstandings of the OOP and unit testing principles, that may lead to wrong perception of test driven design practices.