symfony-cmf/Testing

Container / Kernel Instantiation.

dantleech opened this issue · 3 comments

Kernel instantiation is done with the help of the WebTestCase class, I find this to be more of a hinderance than a benefit.

  1. It "magically" finds the kernel class.
  2. It only allows for one instance of the kernel at one time.
  3. 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

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