I spent time learning the methodologies for writing test code, and I came across a great post from Misko Hevery, where he explains clearly how to approach dependencies when building applications using factories, for example, to load all objects and, therefore, reduce dependency lines that complicate testing.
In his post, he gives a minimal, albeit insightful example of how he installs the application in java, shamelessly quotes below with great respect for the dude:
He then states:
Notice how the code is broken into three phases. Create a factory, create an application, run the application. This makes it verifiable. No matter what your application, you should soar this template. To get single points to the right places, Factory creates only one instance, and then passes that instance to the constructors of all classes, since it calls a new one. See: http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/
I donโt own Java, but I suppose it can be imitated in php, minus the main () method, but where would $ args come from the context of the web application? And initialization?
I would be very interested to see a minimal example of a PHP application under test, or even links to applications that would be considered effective in terms of efficiency. Initialization is what I am interested in, basically. My goal is not to copy-paste, but to learn what experienced OOP coders have developed.
I broke through the code of several popular code libraries: Zend, Symphony, but these frameworks are not executable applications and seem too "too big" for me to understand a clear picture. In addition, several shortcomings were noted in this framework with respect to testing methods. Just a small example, if possible (even if it does not work), will give me better control over the correct OOP linking rules when starting a small application from scratch.
stefgosselin
source share