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

Skip to content

TestContainer should not be @internal #46483

Closed
@ddeboer

Description

@ddeboer

Symfony version(s) affected

6.1.0

Description

#44695 added @return TestContainer to KernelTestCase::getContainer(). However, TestContainer is marked @internal, which makes any calls static::getContainer()->get(MyService::class) invalid, for example to Psalm (and possibly also to IDEs):

ERROR: InternalMethod - MyTest.php:16:49 - The method Symfony\Bundle\FrameworkBundle\Test\TestContainer::get is internal to Symfony but called from MyTest (see https://psalm.dev/175)
        $this->client = static::getContainer()->get(MyService::class);

How to reproduce

use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

final class MyTest extends KernelTestCase
{
    public function test_container_get(): void
    {
        static::getContainer()->get(MyService::class);
    }
}

Possible Solution

Remove @internal from TestContainer.

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