Container / Kernel Instantiation.
dantleech opened this issue · 3 comments
dantleech commented
Kernel instantiation is done with the help of the WebTestCase
class, I find this to be more of a hinderance than a benefit.
- It "magically" finds the kernel class.
- It only allows for one instance of the kernel at one time.
- It makes the task seem much harder than it is.
public function getContainer()
{
$kernel = new AppKernel();
$kernel->boot();
return $kernel->getContainer();
}
The user can then include their actual test kernel themselves (I don't think it is too much to ask).
I would vote to stop extending the WebTestCase
and support a way to get a container instance with a specific configuration, for example:
public function getContainer($config = array(), $env, $debug)
wdyt?
dbu commented
i think that discussion should be done on symfony itself. we simply
build on top of that.
dantleech commented
Well, my question might be: Do we need to build on top of it? In fact, it might even make sense to make things like this into traits.
In that way the user can create their own "base test case" and import things for getting the kernel / container, creating temporary directories, etc etc.
/cc @wouterj
dbu commented
i do agree that the WebTestCase kernel creation is a bit weird. i just
doubt the value of rolling our own thing.
if you think it helps a lot, lets do it and then propose an improvement
for symfony itself (maybe only symfony 4, if its not possible in a BC way)