Using Traits With PHPUnit - Qafoo - PHP

As we already wrote that "Code Reuse By Inheritance" has lots of problems and we consider it a code

» » Using Traits With PHPUnit - Qafoo - PHP , ago, 129 view
Subscribe to our Facebook Bot

As we already wrote that "Code Reuse By Inheritance" has lots of problems and we consider it a code smell. You should always aim to use Dependency Injection, most likely Constructor Injection. But with test cases in PHPUnit we cannot do this because we have no control about how and when our test cases are created. There are a similar problem in other frameworks, like we discussed in "Object Lifecycle Control". We also blogged about traits as a Code Smell, but let me show and explain why they might be fine to use in your test cases.
Read more

2016-11-30T01:02:22Z 250250
Dragplus