Best practices to test protected methods with PHPUnit

Posted by Prem Tiwari | Updated on

In this example, I have shared the best practices to test protected methods with PHPUnit. If you’re using PHP5 (>= 5.3.2) with PHPUnit, you can test your private and protected methods by using reflection to set them to be public prior to running your tests:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers