コード例 #1
0
 /**
  * Get kernel
  *
  * @return KernelInterface
  */
 private function getKernel()
 {
     if (!$this->kernel) {
         if (!self::$bootstrapped) {
             // Avoid Drupal attempt to return a cached page while we are
             // actually unit testing it
             drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
             $GLOBALS['conf']['cache'] = 0;
             drupal_page_is_cacheable(false);
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             self::$bootstrapped = true;
         }
         $this->kernel = $this->createKernelInstance(uniqid('test_'));
         $this->kernel->boot();
         $this->kernel->getContainer()->get('request_stack')->push(\MakinaCorpus\Drupal\Sf\Http\Request::createFromGlobals());
         \Drupal::_setKernel($this->kernel);
     }
     return $this->kernel;
 }