Codeception test reports: Headers already sent in ../vendor/phpunit/phpunit/src/Util/Printer.php on line 109
When I run the test in terminal I see no issue.
When I run "codeception" test in PhpStorm (it has type = functional) I get Codeception test reports: Headers already sent in ../vendor/phpunit/phpunit/src/Util/Printer.php on line 109.
After debugging, I see that it happens at the first line of PhpStorm_Codeception_ReportPrinter::printEvent.
/**
* @param string $eventName
* @param array $params
*/
private function printEvent($eventName, $params = [])
{
$this->write("\n##teamcity[$eventName");
if ($this->flowId) {
$params['flowId'] = $this->flowId;
}
foreach ($params as $key => $value) {
$escapedValue = self::escapeValue($value);
$this->write(" $key='$escapedValue'");
}
$this->write("]\n");
}
PHPUnit\Util\Printer($buffer) gets $buffer = '##teamcity[testCount' and prints it, which breaks the test.
请先登录再写评论。
I had the same problem. When I try to run any of the codeception tests (specifically for Yii2) with the built-in PHPStorm (jetBrains) I get the message:
session_set_cookie_params (): Cannot change session cookie parameters when headers already sent
It is solved simply. We need to add ob_start (); in tests / _bootstrap.php
Detail response at Stackoverflow here: https://stackoverflow.com/a/55040543/7702252
Ivan, thanks for sharing!
Thanks Ivan!!!
Thanks to Ivan, it really fixed my functional codeception tests runing from phpStrom.