function TwigExtensionTest::testTwigExtensionLoaded

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php \Drupal\Tests\system\Functional\Theme\TwigExtensionTest::testTwigExtensionLoaded()
  2. 10 core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php \Drupal\Tests\system\Functional\Theme\TwigExtensionTest::testTwigExtensionLoaded()
  3. 11.x core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php \Drupal\Tests\system\Functional\Theme\TwigExtensionTest::testTwigExtensionLoaded()

Tests that the provided Twig extension loads the service appropriately.

File

core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php, line 38

Class

TwigExtensionTest
Tests Twig extensions.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testTwigExtensionLoaded() {
    $twigService = \Drupal::service('twig');
    $ext = $twigService->getExtension(TestExtension::class);
    $this->assertInstanceOf(TestExtension::class, $ext);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.