function TwigSettingsTest::testTwigDebugOverride
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigDebugOverride()
- 8.9.x core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigDebugOverride()
- 11.x core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigDebugOverride()
Ensures Twig engine debug setting can be overridden.
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ TwigSettingsTest.php, line 52
Class
- TwigSettingsTest
- Tests overriding Twig engine settings via settings.php.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testTwigDebugOverride() : void {
// Enable debug and rebuild the service container.
$parameters = $this->container
->getParameter('twig.config');
$parameters['debug'] = TRUE;
$this->setContainerParameter('twig.config', $parameters);
$this->rebuildContainer();
// Check isDebug() via the Twig service container.
$this->assertTrue($this->container
->get('twig')
->isDebug(), 'Twig debug enabled.');
$this->assertTrue($this->container
->get('twig')
->isAutoReload(), 'Twig automatic reloading is enabled when debug is enabled.');
// Override auto reload when debug is enabled.
$parameters = $this->container
->getParameter('twig.config');
$parameters['auto_reload'] = FALSE;
$this->setContainerParameter('twig.config', $parameters);
$this->rebuildContainer();
$this->assertFalse($this->container
->get('twig')
->isAutoReload(), 'Twig automatic reloading can be disabled when debug is enabled.');
// Disable debug and check the service container again.
$parameters = $this->container
->getParameter('twig.config');
$parameters['debug'] = FALSE;
$this->setContainerParameter('twig.config', $parameters);
$this->rebuildContainer();
$this->assertFalse($this->container
->get('twig')
->isDebug(), 'Twig debug disabled.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.