Skip to content

PHPUnit error with Zend_Session

May 31, 2011 1 min read #phpunit #zend-framework

This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.

Running a test, I ran into this error:

Zend_Session_Exception: Session must be started before any output has been sent to the browser; output started in /usr/share/php/PHPUnit/Util/Printer.php/173
output

In order to solve that, I added a line calling ob_start() to my test bootstrap file.

However, there is a better way!!

Instead, add the following line:

Zend_Session::$_unitTestEnabled = true;
php

This works flawlessly.