2

When testing with zend & phpunit. Header error show on console. I find the error:

Cannot modify header information - headers already sent by (output started at /usr/share/php/PHPUnit/Util/Printer.php:173)

I try to debug with the instructions in some topic Is there a way test STDERR output in PHPUnit? and PHPUnit output causing Zend_Session exceptions. But when use --stderr option, I can not find some output and report of testcase. This is the output on the console:

root@ubuntu:/home/boingonline/www/testunit# phpunit --stderr
PHPUnit 3.5.15 by Sebastian Bergmann.

root@ubuntu:/home/boingonline/www/testunit# 

Any ideas for this problem? Thanks for all answers.

1 Answer 1

5

This is a bug in PHP. Whenever something is output (even on CLI, that's the problem), you cannot use header() calls anymore.

A workaround is to use process isolation for the test with @runInSeparateProcess.

Sign up to request clarification or add additional context in comments.

1 Comment

The link to the PHPUnit documentation is broken: this is a working link for PHPUnit 9.5: @runInSeparateProcess

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.