2009 October

Giorgio Sironi’s Blog: Unit testing view helpers

Testing application based on Zend Framework is generally smooth and easy, especially with help of Zend_Test component. Generally, but not always. Testing plugins or other extensions of some Zend Framework components can be tricky. One of such components is Zend_View and it’s helpers.

The empty constructor is the problem in view helper management, since it gets in the way of simple test code when you write view helpers that make use of other view helpers as collaborators. (…) In this design, the view acts as a Service Locator, and we have no idea which helpers could be called by another one: every helper class could depend on everything else. (…) My very-simple-testing solution would be require helpers to specify their collaborators in the constructor or via setters, implementing Dependency Injection. We cannot change the standard Zend Framework architecture, though, but it’s not a framework’s fault. This solution would have required to build a small automatic dependency injection system, which is not in the scope of Zend Framework 1.x (but will be in 2.x as far as I know).

Tricky and problematic does not mean impossible. In his latest post Giorgio Sironi presents his approach to unit testing Zend_View helpers. He explains problem of unit testing view helpers, proposes few solutions and presents the best one for him.

Federico Cargnelutti’s blog: Database Replication Adapter for Zend Framework Applications

Scalability problems are kind of problems many developers and entrepreneurs would like to have. I your already dealing with such problems, you had to notice important feature missing in Zend_Db – support of database replication.

Database replication is an option that allows the content of one database to be replicated to another database or databases, providing a mechanism to scale out the database. Scaling out the database allows more activities to be processed and more users to access the database by running multiple copies of the databases on different machines.

In a recent post on his blog Federico Cargnuletti presents his implementation of Zend_Db replication adapter. It supports single-master and multi-master architectures, as well as connection status caching. Read his post and code before implementing your own replication adapter – you might have it already done.