-- till <[email protected]> wrote
(on Tuesday, 17 March 2009, 05:21 PM +0100):
> trying to wrap my head around Zend_Test, here are some things I can't
> figure out:
> 
> 1) My app uses setRawHeader(), header() etc. -- for example, inside my
> error controller, or in my index.php to "send" a P3P policy. They all
> fail with similar errors:
> 
> testIfHomeExists(RestControllerTest)
> Cannot modify header information - headers already sent by (output
> started at /usr/local/share/pear/PHPUnit/Util/Printer.php:168)
> /path/www/index.php:23
> 
> Line 23 is a header('...'); call.

Use the response object to set all headers; it's the only way to
guarantee all headers are sent at the appropriate time -- and in CLI
environments (such as unit tests), ensure that no errors are thrown due
to lack of headers in the environment. Unfortunately, there's no way
around this -- header() is very unfriendly to the CLI environment.

> 2) My www/index.php kinda looks like this:
> $app = new Bootstrap('environenment');
> $app->start();
> 
> Now, I thought I could duplicate this in my tests like this:
> 
> ...
> public function setUp()
> {
>   $bootstrap = new Bootstrap('testing');
>   $this->bootstrap = array($bootstrap, 'start');
> }
> 
> ... but to no avail. Whenever I do that, it returns the "entire" html
> of my frontpage, before anything happens. I'm not ruling out that it's
> my fault of course, but I also don't know how to debug this further.

After you set that, call:

    parent::setUp();

Otherwise, it won't bootstrap properly. :-) (This *is* documented and
shown in the examples.)

> I can't share much code, unfortunately, but does anyone have any ideas?
> 
> In general, is Zend_Test ready for "production" yet? I think I pretty
> much run into everything that's still being worked on -- e.g.
> Zend_Session (static issues), cookie-related, etc.. So far, I'm
> pondering to write "regular" unit tests which would involve getting
> the pages through a http client and then parsing them with DOM
> methods.

It's production ready -- I've been using it a ton. The principal issues
lie in the framework itself. For instance, we need to add cookie support
in the response object, and Zend_Session needs to be refactored to make
it easier to test against.

-- 
Matthew Weier O'Phinney
Software Architect | [email protected]
Zend Framework     | http://framework.zend.com/

Reply via email to