spiral / app

Spiral Framework Skeleton HTTP Application: Queue, Console, Cycle ORM
https://spiral.dev/
MIT License
191 stars 20 forks source link

session_set_save_handler(): cannot change save handler when running feature tests #38

Closed dac514 closed 2 years ago

dac514 commented 3 years ago

Hi!

When running the feature tests in \Tests\Feature\BasicTest I'm seeing:

PHPUnit\Framework\Error\Warning: session_set_save_handler(): 
Cannot change save handler when headers already sent in 
/var/www/app/vendor/spiral/framework/src/Session/src/SessionFactory.php at line 63

When I add debug code I get:

if (headers_sent($filename, $linenum)) {
    die("Headers already sent in $filename on line $linenum\n");
}

// Headers already sent in /var/www/app/vendor/phpunit/phpunit/src/Util/Printer.php on line 104

This led me to other people having the same issue here:

Can be fixed by an annotation:

/**
 * @runInSeparateProcess
 */

...but, it would be better if SessionFactory.php was a more clever?