Skip to content

KerneltestCase: Discrepancy between self::$kernel and static::$kernel #47186

@flack

Description

@flack

Symfony version(s) affected

4.4.39

Description

I just updated an ancient Symfony 4.4 app and noticed that in release 4.4.39 out unit tests break due to symfony/framework-bundle@cd52737

After debugging I noticed that this happens because bootKernel assigns the new kernel to self::$kernel, but a few lines down, the container is read from static::$kernel, which in my case is a different class (i.e. my test class extending KernelTestcase):

https://github.com/symfony/framework-bundle/blob/3cbca8f6b93681102cab0fe0e3c23d16e4d0ded3/Test/KernelTestCase.php#L80-L83

How to reproduce

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class MyTest extends WebTestCase
{
    protected static $kernel;

    public function testUserlist()
    {
        static::createClient();
   }
}

Possible Solution

change all occurences to either self or static

Additional Context

No response

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