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

Skip to content

Support TestContainer directly #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2022
Merged

Conversation

ddeboer
Copy link
Contributor

@ddeboer ddeboer commented May 28, 2022

Since Symfony 6.1, KernelTestCase::getContainer() has a @return TestContainer (symfony/symfony#44695), which trips up Psalm:

ERROR: PropertyTypeCoercion - MyTest:16:25 - $this->client expects 'SomeService',  parent type 'null|object' provided (see https://psalm.dev/198)
        $this->client = static::getContainer()->get(SomeService::class);

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(SomeService::class);

Symfony’s TestContainer is indeed marked @internal. A first step is to add Symfony\Bundle\FrameworkBundle\Test\TestContainer to ContainerHandler, although it doesn’t yet fully resolve the problem.

See also symfony/symfony#46483.

Copy link
Member

@seferov seferov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddeboer thank you!

@seferov seferov merged commit fa5fe8b into psalm:master May 28, 2022
@ddeboer ddeboer deleted the fix-test-container branch May 28, 2022 11:16
@ddeboer ddeboer mentioned this pull request Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants