Context:
I have tried the solution in PHPUnit code coverage session already started, with no success. I am still getting the error when I try to generate the code coverage. And I am stumped on what is causing the error. I have put the information showing that I have used the answer from the linked question and the proof of the issue still happening. I am running in a Docker instance running CentOS.
Question:
How does one get code coverage to work? And why am i getting this error session_start(): Cannot start session when headers already sent
?
Versions:
PHP 7.2.7
PHPUnit 7.3.1
Outputs:
When I run without code coverage, I get the list of successful tests.
[root@fada2474faea iop]# vendor/bin/phpunit tests/file6test.php --coverage-html coverage
PHPUnit 7.3.1 by Sebastian Bergmann and contributors.
session_start(): Cannot start session when headers already sent
Tests passes without code coverage enabled.
[root@fada2474faea iop]# vendor/bin/phpunit tests/file6test.php
PHPUnit 7.3.1 by Sebastian Bergmann and contributors.
..... 5 / 5 (100%)
Time: 46 ms, Memory: 6.00MB
OK (5 tests, 5 assertions)
the code updated with the answer from the other question linked
[root@fada2474faea iop]# grep -i -R -A1 -B2 session_start *.php
access.php-if(session_status() == PHP_SESSION_NONE)
access.php-{
access.php: session_start();
access.php-}
--
file1.php- if(session_status() == PHP_SESSION_NONE)
file1.php- {
file1.php: session_start();
file1.php- }
--
file2.php- if(session_status() == PHP_SESSION_NONE)
file2.php- {
file2.php: session_start();
file2.php- }
--
logout.php-if(session_status() == PHP_SESSION_NONE)
logout.php-{
logout.php: session_start();
logout.php-}
--
file3.php- if(session_status() == PHP_SESSION_NONE)
file3.php- {
file3.php: session_start();
file3.php- }
--
api.php-if(session_status() == PHP_SESSION_NONE)
api.php-{
api.php: session_start();
api.php-}
--
file4.php-if(session_status() == PHP_SESSION_NONE)
file4.php-{
file4.php: session_start();
file4.php-}
--
file5.php- if(session_status() == PHP_SESSION_NONE)
file5.php- {
file5.php: session_start();
file5.php- }