You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cantSeeAuthentication()/dontSeeAuthentication() does not work due to missing service #138
Calling cantSeeAuthentication()/dontSeeAuthentication() fails with the error message
Service security.helper is not available in container.
If the service isn't injected anywhere in your app, you need to set it to `public` in your `config/services_test.php`/`.yaml`,
see https://symfony.com/doc/current/testing.html#accessing-the-container
I updated this project to Symfony 5.3 using the new security system and according to our tests both methods are working correctly.
If the service isn't injected anywhere in your app, you need to set it to public in your config/services_test.php/.yaml
The error message gives you a little clue as to what the problem may be.
In the case of our test project, we do not have the security service defined as public in a test configuration file services_test. *, In our case, that service is injected into our SecurityAuthenticator class of the new Symfony security system, although actually that service is not used anywhere in that class.
So a workaround would be to inject the service security.helper somewhere in my app in order to avoid being removed during compilation of the DI container.
I wonder if there is a way to ensure that the service is always available when using the symfony module.
Instead of doing a ghost injection of the security service in the app I defined the alias 'security.helper' as public in the test environment thanks to the services_test.php/.yaml file.
I wonder if there is a way to ensure that the service is always available when using the symfony module.
Regarding this question... I think that, even if there is a way to define that specific service as public in the test environment programmatically we probably should not do it, since each user should be able to decide exactly which services are public in their tests and which not.
Fail Service security.helper is not available in container.
If the service isn't injected anywhere in your app, you need to set it to `public` in your `config/services_test.php`/`.yaml`,
see https://symfony.com/doc/current/testing.html#accessing-the-container
So the solution is to improve the error message a bit more so that each user can define the alias for that service himself.
I'll close this issue when I have the PR by modifying that documentation.
Activity
TavoNiievez commentedon Jun 16, 2021
We have a test project (codeception/symfony-module-tests) that has tests with this module.
I updated this project to Symfony 5.3 using the new security system and according to our tests both methods are working correctly.
The error message gives you a little clue as to what the problem may be.
In the case of our test project, we do not have the security service defined as public in a test configuration file
services_test. *, In our case, that service is injected into ourSecurityAuthenticatorclass of the new Symfony security system, although actually that service is not used anywhere in that class.W0rma commentedon Jun 17, 2021
Thank you for the quick reply.
So a workaround would be to inject the service
security.helpersomewhere in my app in order to avoid being removed during compilation of the DI container.I wonder if there is a way to ensure that the service is always available when using the symfony module.
TavoNiievez commentedon Sep 2, 2021
I just made the changes in
symfony-module-tests:https://github.com/Codeception/symfony-module-tests/pull/19/files
Instead of doing a ghost injection of the security service in the app I defined the alias
'security.helper'aspublicin thetestenvironment thanks to theservices_test.php/.yamlfile.Regarding this question... I think that, even if there is a way to define that specific service as
publicin thetestenvironment programmatically we probably should not do it, since each user should be able to decide exactly which services arepublicin their tests and which not.So the solution is to improve the error message a bit more so that each user can define the alias for that service himself.
I'll close this issue when I have the PR by modifying that documentation.
TavoNiievez commentedon Oct 7, 2021
PR #142, #144 and #145 add the documentation that was required to close this issue.