I'm trying to access the container in a Symfony2 WebTestCase and i'm getting NULL. Any ideas? Here's my code:
$this->client = static::createClient();
$container = $this->client->getContainer();
Assuming that you extend from WebTestCase
class, you should call $this->createClient()
instead of static method.
In case if you call this method as static, you should execute boot()
method
static::$kernel = static::createKernel($options);
static::$kernel->boot();
$client = static::$kernel->getContainer()->get('test.client');
$client->setServerParameters($server);
Be sure to create client inside setUp()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With