You are here

TwigLoaderTest.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/TwigLoaderTest.php

File

core/modules/system/src/Tests/Theme/TwigLoaderTest.php
View source
<?php

/**
 * @file
 * Contains \Drupal\system\Tests\Theme\TwigLoaderTest.
 */
namespace Drupal\system\Tests\Theme;

use Drupal\simpletest\WebTestBase;

/**
 * Tests adding Twig loaders.
 *
 * @group Theme
 */
class TwigLoaderTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'twig_loader_test',
  ];

  /**
   * Tests adding an additional twig loader to the loader chain.
   */
  public function testTwigLoaderAddition() {
    $environment = \Drupal::service('twig');
    $template = $environment
      ->loadTemplate('kittens');
    $this
      ->assertEqual($template
      ->render(array()), 'kittens', 'Passing "kittens" to the custom Twig loader returns "kittens".');
    $template = $environment
      ->loadTemplate('meow');
    $this
      ->assertEqual($template
      ->render(array()), 'cats', 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
  }

}

Classes

Namesort descending Description
TwigLoaderTest Tests adding Twig loaders.