views:

77

answers:

1

I'd like to implement widget-ized Zend controllers in a test-driven way. By widget-ized I mean, for instance, a list controller that outputs elements, calling for each of them $this->action('element', …) view helper in its view script (list.phtml). Thus, the rendering of each element in the list is handled by a dedicated “element” controller, and is configurable, or even can be changed at runtime. See “Action View Helper” section at http://framework.zend.com/manual/en/zend.view.helpers.html

The question is: how do I mock and sense this $this->action('element', …) call best? Do I have to rewrite all the default ZF request routing and plugin loading logic for the tests, or is there a shortcut?

I'm using PHPUnit, if that matters.

+1  A: 

Not the answer to your actual question, but I think using the actionstack for widgets is bad practice in ZF.
Consider reading Why the Zend Framework Actionstack is Evil by a ZF-Contributor.

Have a look at Piwik, a ZF-based web analytics software. They use a fully widget-ized and configurable interface.

Benjamin Cremer