简体   繁体   中英

'PHPUnit_Framework_Error_Warning' with message 'session_regenerate_id(): Cannot regenerate session id - headers already sent'

I ran into this problem writing controller tests for logging in. I found an answer for the Yii framework but I use Zend. The answer was to use ob_start() but it didn't work for me until I figured out where to put it. I ended up landing on having it at the top of my Bootstrap.php file. If anyone else has figured out a better way of doing this please let me know

Please try to set:

Zend_Session::$_unitTestEnabled = true;

In your tests, could work.

Another solution could be to redirect the PHPUnit output, so that it doesn't interrupt the html output.

phpunit --stderr controllerTest.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM