I have a problem with my PHPUnit test on Symfony2. To connect to my application, I use a web service, so I created a UserProvider. In my function loadUserByUsername I use Symfony2 parameters saved in app/config/parameters.yml. As I'm not in a controller I need to use the global variable $kernel and get my args like this:
global $kernel;
$url = $kernel->getContainer()-getParameter('myparam');
When I use my application, it works, but when I write my test like this:
$crawler = $client->request('GET', '/login');
$form = $crawler->selectButton('submit')->form();
$form['_username'] = $username;
$form['_password'] = $pass;
and execute PHPUnit I get this error :
Fatal error : Call to a member function getContainer()
How can I access Symfony2 parameters or use getContainer when I execute PHPUnit?