TwigLoaderTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\BrowserTestBase;
class TwigLoaderTest extends BrowserTestBase {
public static $modules = [
'twig_loader_test',
];
protected $defaultTheme = 'stark';
public function testTwigLoaderAddition() {
$environment = \Drupal::service('twig');
$template = $environment
->loadTemplate('kittens');
$this
->assertEqual($template
->render([]), 'kittens', 'Passing "kittens" to the custom Twig loader returns "kittens".');
$template = $environment
->loadTemplate('meow');
$this
->assertEqual($template
->render([]), 'cats', 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
}
}