Skip to content
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

Testing standalone bundle - got 'Could not find service "test.service_container".' #41715

Closed
smilesrg opened this issue Jun 15, 2021 · 3 comments

Comments

@smilesrg
Copy link
Contributor

smilesrg commented Jun 15, 2021

I'm writing a standalone bundle and trying to test it. But got an error:

LogicException: Could not find service "test.service_container". Try updating the "framework.test" config to "true".

I couldn't find anything in the documentation related to this error. How can I fix that?

UPD: I tried obvious solution by creating config/config_test.yml and even renamed extension to .yaml but it didn't help, content of the file is:

framework:
    test: true

The content of phpunit.xml.dist (renamed to .txt due to github limitations):
phpunit.txt

@xabbuh
Copy link
Member

xabbuh commented Jun 15, 2021

Can you create a small example application that allows to reproduce your issue?

@smilesrg
Copy link
Contributor Author

smilesrg commented Jun 15, 2021

Sure, you can check out this https://github.com/inspector-apm/inspector-symfony/tree/0b5af59e85766f33fa5045bccc8c1929587bd4d8 and try to launch tests

@nicolas-grekas
Copy link
Member

That's because in 5.3 we unconditionally use the test.service_container service to get the session.
This has been fixed on 5.4 in #41530, we might want to backport part of it.
PR welcome!

nicolas-grekas added a commit that referenced this issue Jun 17, 2021
…_container" (smilesrg)

This PR was merged into the 5.2 branch.

Discussion
----------

[FrameworkBundle] fix Could not find service "test.service_container"

| Q             | A
| ------------- | ---
| Branch?       |  5.2, needs to be ported to 5.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #41715
| License       | MIT

Partial backport of #41530
Related to #41715 and #41530

When launching phpunit, got an error:
`LogicException: Could not find service "test.service_container". Try updating the "framework.test" config to "true".`

```
There was 1 error:

1) App\Symfony\Bundle\Tests\Integration\IntegrationTest::testServiceWiringWithConfiguration
LogicException: Could not find service "test.service_container". Try updating the "framework.test" config to "true".

/Projects/app/vendor/symfony/framework-bundle/Test/KernelTestCase.php:109
/Projects/app/tests/integration/IntegrationTest.php:23

Caused by
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "test.service_container". Did you mean this: "service_container"?

/Projects/app/vendor/symfony/dependency-injection/Container.php:280
/Projects/app/vendor/symfony/dependency-injection/Container.php:228
/Projects/app/vendor/symfony/framework-bundle/Test/KernelTestCase.php:107
/Projects/app/tests/integration/IntegrationTest.php:23
```

/cc `@xabbuh`  `@nicolas`-grekas

Commits
-------

0748b52 bug #41715: [FrameworkBundle] Partial backport of PR#41530
nicolas-grekas added a commit that referenced this issue Jun 17, 2021
* 5.2:
  bug #41715: [FrameworkBundle] Partial backport of PR#41530
  Fix some typos in Greek language
  Remove TLS related options when not using TLS
nicolas-grekas added a commit that referenced this issue Jun 17, 2021
* 5.3:
  [FrameworkBundle] fix leftover
  [Uid] fix performance and prevent collisions with the real clock_seq
  Fix RequestContext not updated
  bug #41715: [FrameworkBundle] Partial backport of PR#41530
  [Security] Restore extension point in MessageDigestPasswordEncoder
  Fix some typos in Greek language
  [Security] Fix deprecation notice on TokenInterface::getUser() stringable return
  Remove TLS related options when not using TLS
nicolas-grekas added a commit that referenced this issue Jun 17, 2021
* 5.4:
  [FrameworkBundle] fix leftover
  [Uid] fix performance and prevent collisions with the real clock_seq
  Fix RequestContext not updated
  bug #41715: [FrameworkBundle] Partial backport of PR#41530
  [Security] Restore extension point in MessageDigestPasswordEncoder
  Fix some typos in Greek language
  [Security] Fix deprecation notice on TokenInterface::getUser() stringable return
  Remove TLS related options when not using TLS
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

No branches or pull requests

3 participants