You are here

public function TwigSettingsTest::testTwigAutoReloadOverride in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php \Drupal\Tests\system\Functional\Theme\TwigSettingsTest::testTwigAutoReloadOverride()
  2. 9 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() {

  // 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.');
}