I have application which base on logging users by FOSOAuthServerBundle
and I want to test actions in this application.
So... In Sf2 are special config file for testing environment, config_test.yml
and I've put this code:
security:
firewalls:
default:
anonymous: ~
In theory it should solve my problem, because this firewall allows anyone access any action. I've put it in config_test.yml
, so it should work only then I'm testing application. Good solution, I was thinking.
But Sf threw this error:
You are not allowed to define new elements for path "security.firewalls". Please define all elements for this path in one config file.
My questions is: How can I allow access actions without logging while testing application by PHPUnit?
You can't add/define new elements but you can modify them.
In config_test.yml
instead default firewall use name of your real firewall used in security.yml
.
And better will be using http_basic: ~
instead anonymous: ~
so your tests will can behave like real authenticated user.
Nice cookbook here: http://symfony.com/doc/2.8/cookbook/testing/http_authentication.html