shutdown example

    $this->assertNotEquals($a$c);
    $this->assertNotEquals($a$d);
  }

  /** * Reboots the kernel to set custom translations in Settings. */
  protected function rebootAndPrepareSettings() {
    // Reboot the container so that different services are injected and the new     // settings are picked.     $kernel = $this->container->get('kernel');
    $kernel->shutdown();
    $kernel->boot();
    $settings = Settings::getAll();
    $settings['locale_custom_strings_de'] = ['' => ['Example @number' => 'Example @number translated']];
    // Recreate the settings static.     new Settings($settings);
  }

}
return new static::$class($env$debug);
    }

    /** * Shuts the kernel down if it was used in the test - called by the tearDown method by default. */
    protected static function ensureKernelShutdown()
    {
        if (null !== static::$kernel) {
            static::$kernel->boot();
            $container = static::$kernel->getContainer();
            static::$kernel->shutdown();
            static::$booted = false;

            if ($container instanceof ResetInterface) {
                $container->reset();
            }
        }
    }
}
protected function assertPostConditions(): void {
    // Execute registered Drupal shutdown functions prior to tearing down.     // @see _drupal_shutdown_function()     $callbacks = &drupal_register_shutdown_function();
    while ($callback = array_shift($callbacks)) {
      call_user_func_array($callback['callback']$callback['arguments']);
    }

    // Shut down the kernel (if bootKernel() was called).     // @see \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest     if ($this->container) {
      $this->container->get('kernel')->shutdown();
    }

    parent::assertPostConditions();
  }

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    // Destroy the testing kernel.     if (isset($this->kernel)) {
      
$newTestKernel = new $kernelClass(
            'test',
            true,
            new StaticKernelPluginLoader(KernelLifecycleManager::getClassLoader()),
            Uuid::randomHex(),
            '2.2.2',
            $this->getContainer()->get(Connection::class)
        );

        $newTestKernel->boot();
        $cacheDir = $newTestKernel->getCacheDir();
        $newTestKernel->shutdown();

        return $cacheDir;
    }

    private function createUploadedFile(): UploadedFile
    {
        return new UploadedFile(self::PLUGIN_ZIP_FIXTURE_PATH, self::TEST_PLUGIN_ZIP_NAME, null, null, true);
    }

    private function getPluginManagementService(): PluginManagementService
    {
        
public function shutdown(): void
    {
        if (!$this->booted) {
            return;
        }

        // keep connection when rebooting         if (!$this->rebooting) {
            self::$connection = null;
        }

        parent::shutdown();
    }

    public function reboot(?string $warmupDir, ?KernelPluginLoader $pluginLoader = null, ?string $cacheId = null): void
    {
        $this->rebooting = true;

        try {
            if ($pluginLoader) {
                $this->pluginLoader = $pluginLoader;
            }
            if ($cacheId) {
                
'test',
                true,
                new StaticKernelPluginLoader($classLoader),
                Uuid::randomHex(),
                '1.0.0@' . $i . '1eec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33',
                $original->getContainer()->get(Connection::class)
            );

            $kernel->boot();
            $oldCacheDir = $kernel->getCacheDir();
            static::assertFileExists($oldCacheDir);
            $kernel->shutdown();
            $oldCacheDirs[] = $oldCacheDir;
        }
        $oldCacheDirs = array_unique($oldCacheDirs);

        static::assertCount(2, $oldCacheDirs);

        $second = KernelLifecycleManager::getKernel();
        $second->boot();
        static::assertFileExists($second->getCacheDir());

        static::assertNotContains($second->getCacheDir()$oldCacheDirs);

        


    public function testShutdownCallsShutdownOnAllBundles()
    {
        $bundle = $this->createMock(Bundle::class);
        $bundle->expects($this->once())
            ->method('shutdown');

        $kernel = $this->getKernel([][$bundle]);

        $kernel->boot();
        $kernel->shutdown();
    }

    public function testShutdownGivesNullContainerToAllBundles()
    {
        $bundle = $this->createMock(Bundle::class);
        $bundle->expects($this->exactly(2))
            ->method('setContainer')
            ->willReturnCallback(function D$container) {
                if (null !== $container) {
                    $this->assertInstanceOf(ContainerInterface::class$container);
                }
            })

    }

    /** * Class destructor. Shutdown log writers * * @return void */
    public function __destruct()
    {
        foreach($this->_writers as $writer) {
            $writer->shutdown();
        }
    }

    /** * Undefined method handler allows a shortcut: * $log->priorityName('message') * instead of * $log->log('message', Zend_Log::PRIORITY_NAME) * * @param string $method priority name * @param string $params message to log * @return void * @throws Zend_Log_Exception */
/** * Shuts the kernel down if it was used in the test. */
    public static function ensureKernelShutdown(): void
    {
        if (static::$kernel === null) {
            return;
        }

        $container = static::$kernel->getContainer();
        static::$kernel->shutdown();

        if ($container instanceof ResetInterface) {
            $container->reset();
        }

        static::$kernel = null;
    }

    public static function getConnection(): Connection
    {
        if (!static::$connection) {
            

                $this->kernel->registerContainerConfiguration(...\func_get_args());
            }

            public function boot(): void
            {
                $this->kernel->boot();
            }

            public function shutdown(): void
            {
                $this->kernel->shutdown();
            }

            public function locateResource(string $name): string
            {
                return $this->kernel->locateResource(...\func_get_args());
            }

            public function getEnvironment(): string
            {
                return $this->kernel->getEnvironment();
            }

            


    /** * @param Request $request */
    protected function doRequest(object $request): Response
    {
        // avoid shutting down the Kernel if no request has been performed yet         // WebTestCase::createClient() boots the Kernel but do not handle a request         if ($this->hasPerformedRequest && $this->reboot) {
            $this->kernel->boot();
            $this->kernel->shutdown();
        } else {
            $this->hasPerformedRequest = true;
        }

        if ($this->profiler) {
            $this->profiler = false;

            $this->kernel->boot();
            $this->getContainer()->get('profiler')->enable();
        }

        


  /** * {@inheritdoc} */
  protected function tearDown(): void {
    parent::tearDown();

    // Destroy the testing kernel.     if (isset($this->kernel)) {
      $this->cleanupEnvironment();
      $this->kernel->shutdown();
    }

    // Ensure that internal logged in variable is reset.     $this->loggedInUser = FALSE;

    if ($this->mink) {
      $this->mink->stopSessions();
    }

    // Restore original shutdown callbacks.     if (function_exists('drupal_register_shutdown_function')) {
      
$bundle->boot();
        }

        $this->booted = true;
    }

    /** * @return void */
    public function reboot(?string $warmupDir)
    {
        $this->shutdown();
        $this->warmupDir = $warmupDir;
        $this->boot();
    }

    /** * @return void */
    public function terminate(Request $request, Response $response)
    {
        if (false === $this->booted) {
            return;
        }
$bundle->boot();
        }

        $this->booted = true;
    }

    /** * @return void */
    public function reboot(?string $warmupDir)
    {
        $this->shutdown();
        $this->warmupDir = $warmupDir;
        $this->boot();
    }

    /** * @return void */
    public function terminate(Request $request, Response $response)
    {
        if (false === $this->booted) {
            return;
        }
$loader->getSourceContext('@__main__\/core/tests/fixtures/files/sql-2.sql');
      $this->fail('Expected exception not thrown');
    }
    catch (LoaderError $e) {
      $this->assertStringContainsString('Template @__main__\/core/tests/fixtures/files/sql-2.sql has an invalid file extension (sql). Only templates ending in one of css, html, js, svg, twig are allowed. Set the twig.config.allowed_file_extensions container parameter to customize the allowed file extensions', $e->getMessage());
    }

    // Allow SQL files to be included.     $twig_config = $this->container->getParameter('twig.config');
    $twig_config['allowed_file_extensions'][] = 'sql';
    $this->twigConfig = $twig_config;
    $this->container->get('kernel')->shutdown();
    $this->container->get('kernel')->boot();
    /** @var \Drupal\Core\Template\Loader\FilesystemLoader $loader */
    $loader = \Drupal::service('twig.loader.filesystem');
    $source = $loader->getSourceContext('@__main__\/core/tests/fixtures/files/sql-2.sql');
    $this->assertSame(file_get_contents('core/tests/fixtures/files/sql-2.sql')$source->getCode());

    // Test the fallback to the default list of extensions provided by the     // class.     $this->assertSame(['css', 'html', 'js', 'svg', 'twig', 'sql'], \Drupal::getContainer()->getParameter('twig.config')['allowed_file_extensions']);
    unset($twig_config['allowed_file_extensions']);
    $this->twigConfig = $twig_config;
    
Home | Imprint | This part of the site doesn't use cookies.