function TwigSettingsTest::testTwigAutoReloadOverride

Ensures Twig template auto reload setting can be overridden.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php, line 36
Contains \Drupal\system\Tests\Theme\TwigSettingsTest.

Class

TwigSettingsTest
Tests Twig engine configuration via settings.php.

Namespace

Drupal\system\Tests\Theme

Code

function testTwigAutoReloadOverride() {

  // Enable auto reload and rebuild the service container.
  $this
    ->settingsSet('twig_auto_reload', TRUE);
  $this
    ->rebuildContainer();

  // Check isAutoReload() via the Twig service container.
  $this
    ->assertTrue(drupal_container()
    ->get('twig')
    ->isAutoReload(), 'Automatic reloading of Twig templates enabled.');

  // Disable auto reload and check the service container again.
  $this
    ->settingsSet('twig_auto_reload', FALSE);
  $this
    ->rebuildContainer();
  $this
    ->assertFalse(drupal_container()
    ->get('twig')
    ->isAutoReload(), 'Automatic reloading of Twig templates disabled.');
}