function TwigSettingsTest::testTwigDebugOverride

Ensures Twig engine debug setting can be overridden.

File

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

Class

TwigSettingsTest
Tests Twig engine configuration via settings.php.

Namespace

Drupal\system\Tests\Theme

Code

function testTwigDebugOverride() {

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

  // Check isDebug() via the Twig service container.
  $this
    ->assertTrue(drupal_container()
    ->get('twig')
    ->isDebug(), 'Twig debug enabled.');
  $this
    ->assertTrue(drupal_container()
    ->get('twig')
    ->isAutoReload(), 'Twig automatic reloading is enabled when debug is enabled.');

  // Override auto reload when debug is enabled.
  $this
    ->settingsSet('twig_auto_reload', FALSE);
  $this
    ->rebuildContainer();
  $this
    ->assertFalse(drupal_container()
    ->get('twig')
    ->isAutoReload(), 'Twig automatic reloading can be disabled when debug is enabled.');

  // Disable debug and check the service container again.
  $this
    ->settingsSet('twig_debug', FALSE);
  $this
    ->rebuildContainer();
  $this
    ->assertFalse(drupal_container()
    ->get('twig')
    ->isDebug(), 'Twig debug disabled.');
}