I use the FacebookBundle to authenticate users in my Symfony2 application. However, I would like to create functional tests with phpunit which uses an authenticated user.
Moreover, I don’t want to use a facebook user for this, but harcoded one.
Does anybody know how to implement this?
It’s actually quite simple.
Setup
security.ymlfor test environment (it’s a snippet from Symfony 2.0-RC3)As you can see there is HTTP Authentication defined. So now, all you have to do is to setup a client in functional test:
This link might be useful: http://symfony.com/doc/current/testing.html