PHPUnit - Warning: "Header already sent" I'm trying to cover the plugin controller with unit tests, but when I try to run phpunit this error shows up:


  Warning: Cannot modify header information - headers already sent by (output started at /craft/app/vendor/phpunit/phpunit/src/Util/Printer.php:172 ) in /craft/craft/app/helpers/JsonHelper.php on line 25


The same error indicates also line 26 and 27 of JsonHelper.php

Did someone already had this issue? Can somebody help me on this?

Thank you very much.
You could try setting PHPUnit's @runInSeparateProcess flag, as discussed here.

However, it sounds as though you're attempting to use PHPUnit for acceptance or integration tests, when it's really designed to be used for unit testing.

A couple of options:


You could mock the JsonHelper::sendJsonHeaders method, but that may prove tricky;
You could use something like Behat for integration testing. This may be more appropriate for a controller.


Stephen