1

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

It works, thank you. In my case - I use FOSOAuthServerBundle http_basic wont work - in prod config I have anonymous: false and should also overwrite it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.