Want to test PHP headers with PHPUnit? The issue is that PHPUnit will print a header to the screen and at that point you can’t add more headers. The work around is to run the test in an isolated process.
Here is an example:
class FooTest extends PHPUnit_Framework_TestCase
public function testBar()
header('Location : http://foo.com');
The output will be like:
$ phpunit FooTest.php
PHPUnit 3.6.10 by Sebastian Bergmann.
Time: 1 second, Memory: 9.00Mb
OK (1 test, 0 assertions)
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.