class TwigLoaderTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Kernel/Theme/TwigLoaderTest.php \Drupal\Tests\system\Kernel\Theme\TwigLoaderTest
- 10 core/modules/system/tests/src/Kernel/Theme/TwigLoaderTest.php \Drupal\Tests\system\Kernel\Theme\TwigLoaderTest
- 8.9.x core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php \Drupal\Tests\system\Functional\Theme\TwigLoaderTest
Tests adding Twig loaders.
@group Theme
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Theme\TwigLoaderTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of TwigLoaderTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ TwigLoaderTest.php, line 12
Namespace
Drupal\Tests\system\Functional\ThemeView source
class TwigLoaderTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'twig_loader_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests adding an additional twig loader to the loader chain.
*/
public function testTwigLoaderAddition() {
$environment = \Drupal::service('twig');
$template = $environment->loadTemplate('kittens');
$this->assertEquals('kittens', $template->render([]), 'Passing "kittens" to the custom Twig loader returns "kittens".');
$template = $environment->loadTemplate('meow');
$this->assertEquals('cats', $template->render([]), 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.