function TwigSettingsTest::testTwigAutoReloadOverride

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigAutoReloadOverride()
  2. 8.9.x core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigAutoReloadOverride()
  3. 10 core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigAutoReloadOverride()

Ensures Twig template auto reload setting can be overridden.

File

core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php, line 30

Class

TwigSettingsTest
Tests overriding Twig engine settings via settings.php.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testTwigAutoReloadOverride() : void {
    // Enable auto reload and rebuild the service container.
    $parameters = $this->container
        ->getParameter('twig.config');
    $parameters['auto_reload'] = TRUE;
    $this->setContainerParameter('twig.config', $parameters);
    $this->rebuildContainer();
    // Check isAutoReload() via the Twig service container.
    $this->assertTrue($this->container
        ->get('twig')
        ->isAutoReload(), 'Automatic reloading of Twig templates enabled.');
    // Disable auto reload and check the service container again.
    $parameters = $this->container
        ->getParameter('twig.config');
    $parameters['auto_reload'] = FALSE;
    $this->setContainerParameter('twig.config', $parameters);
    $this->rebuildContainer();
    $this->assertFalse($this->container
        ->get('twig')
        ->isAutoReload(), 'Automatic reloading of Twig templates disabled.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.