trait ExtensionListTestTrait

Same name in other branches
  1. 9 core/tests/Drupal/Tests/ExtensionListTestTrait.php \Drupal\Tests\ExtensionListTestTrait
  2. 11.x core/tests/Drupal/Tests/ExtensionListTestTrait.php \Drupal\Tests\ExtensionListTestTrait

Provides extension list methods.

Hierarchy

2 files declare their use of ExtensionListTestTrait
FilePathTest.php in core/modules/migrate_drupal_ui/tests/src/Functional/d7/FilePathTest.php
KernelTestBase.php in core/tests/Drupal/KernelTests/KernelTestBase.php

File

core/tests/Drupal/Tests/ExtensionListTestTrait.php, line 10

Namespace

Drupal\Tests
View source
trait ExtensionListTestTrait {
    
    /**
     * Gets the path for the specified module.
     *
     * @param string $module_name
     *   The module name.
     *
     * @return string
     *   The Drupal-root relative path to the module directory.
     *
     * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException
     *   If the module does not exist.
     */
    protected function getModulePath(string $module_name) : string {
        return \Drupal::service('extension.list.module')->getPath($module_name);
    }
    
    /**
     * Gets the path for the specified theme.
     *
     * @param string $theme_name
     *   The theme name.
     *
     * @return string
     *   The Drupal-root relative path to the theme directory.
     *
     * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException
     *   If the theme does not exist.
     */
    protected function getThemePath(string $theme_name) : string {
        return \Drupal::service('extension.list.theme')->getPath($theme_name);
    }

}

Members

Title Sort descending Modifiers Object type Summary
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.

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