Yes, you can!! Part I

Hi there,

Does it ring a bell those situations where you need a new functionality for your code and you cannot use third party software straight off? 

A quick assessment along with a decision has to be made quickly in order to either doing something from the scratch (in a decent time) to fit the needs, or go through a tough process of adapting the legacy old code base to make it compatible with the third party system.

Both situations imply risks and you have to reach a trade-off depending on the context. By and large, we are so used to rely on frameworks and packages that encapsulate some kind of feature, that we become lazy when it comes to build something we know it already exists, so our first approach is to try to adapt. 

Since CodeIgniter (CI) turns out to be unfriendly in terms of testability, adopting the PHPUnit framework becomes an unpleasant task. Given my company current context, going through a massive change of the framework core is simply not an option, so, eventually, I had to face the initial option, aka DIY. 

Despite the fact that we may have a terrible feeling of reinventing the wheel (in other words, a miserably waste of time), surprisingly, we very quickly realise that, actually, what we need is just bit portion of the whole 3rd party package functionality so far.

Being myself into the quest of being a better professional, I decided to build my own custom php-unit micro framework to proceed with code refactors.

Folder structure



The core is made up of two classes: CITestCase and the basic HtmlPrinter (implements OutputPrinter) for showing the tests results. Since we need the CI framework to bootstrap through index.php, the application entry point is a Test controller, accessed via HTTP request:

/test/module/run

Go to Part II

Comments

Popular posts from this blog

Bulk Inserts and the Performance Holy Grial (Part II)

Legacy code concepts II: the Seam Model

Bulk Inserts and the Performance Holy Grial (Part I)