Rebuild drupal_container().
Use this to build a new kernel and service container. For example, when the list of enabled modules is changed via the internal browser, in which case the test process still contains an old kernel and service container with an old module list.
@todo Fix http://drupal.org/node/1708692 so that module enable/disable changes are immediately reflected in drupal_container(). Until then, tests can invoke this workaround when requiring services from newly enabled modules to be immediately available in the same request.
TestBase::prepareEnvironment()
protected function rebuildContainer() {
$this->kernel = new DrupalKernel('testing', FALSE, drupal_classloader(), FALSE);
$this->kernel
->boot();
// DrupalKernel replaces the container in drupal_container() with a
// different object, so we need to replace the instance on this test class.
$this->container = drupal_container();
}