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

Skip to content

How to test unused private services #9890

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

Closed
komik966 opened this issue Jun 6, 2018 · 2 comments
Closed

How to test unused private services #9890

komik966 opened this issue Jun 6, 2018 · 2 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Testing
Milestone

Comments

@komik966
Copy link

komik966 commented Jun 6, 2018

In Symfony 4.1 appeared nice feature: https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing
As mentioned symfony/symfony#26499 (comment) removing unused private services from test.service_container is intended behaviour.

In my bundle (call it bundle A) I've private service which will be type-hinted in other bundles, but not in bundle A.
Is there optimal way to write tests for this service in bundle A?

@xabbuh xabbuh added the Testing label Jun 7, 2018
@nicolas-grekas
Copy link
Member

Hi, yes: in your test configuration you can create a public alias to this service, then access it through this alias. I'd recommend to name the alias by prefixing the aliased service with the test. prefix.
Doc PR welcome if you'd like to improve it.

@HeahDude HeahDude added the actionable Clear and specific issues ready for anyone to take them. label Jul 1, 2018
@HeahDude HeahDude added this to the 4.0 milestone Jul 1, 2018
@HeahDude
Copy link
Contributor

HeahDude commented Jul 1, 2018

Closing as duplicate of #8097. Thanks!

@HeahDude HeahDude closed this as completed Jul 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Testing
Projects
None yet
Development

No branches or pull requests

4 participants