Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PHPUnit Test header already send by "phpunit-5.7/src/Util/Printer.php" #25615

Closed
@rehoehle

Description

@rehoehle
Q A
Bug report? yes
Symfony version 3.4.1
PHPUnit 5.7.26

I have a problem after the upgrade to symfony 3.4. I have a login in my unit test. I've implemented the login like the documentation describes here:

https://symfony.com/doc/current/testing/http_authentication.html

I use that code for years now and before 3.4 is was working well.

$session = $client->getContainer()->get('session');
$token = new UsernamePasswordToken($testUser, $testUser->getPassword(), $firewall, $roles);
$session->set('_security_'.$firewall, serialize($token));
$session->save();

$cookie = new Cookie($session->getName(), $session->getId());
$client->getCookieJar()->set($cookie);

if i run the phpunit command over the bridge. I get the following error:

#bin/simple-phpunit
1) Tests\APIBundle\Controller\AutoresponderApiControllerTest::testAutoresponderInsAPI
RuntimeException: Failed to start the session because headers have already been sent by "/xxxx/.phpunit/phpunit-5.7/src/Util/Printer.php" at line 110.

/xxx/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:141
/xxx/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:302
/xxx/vendor/symfony/http-foundation/Session/Session.php:260
/xxx/vendor/symfony/http-foundation/Session/Session.php:80
/xxx/tests/MainBundle/ExtendedWebTestCase.php:151
/xxx/tests/MainBundle/ExtendedWebTestCase.php:62

without the lines with the login it's working.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions