You are here

class ThemeNotUsingClassyLibraryTest in Drupal 8

Tests that themes do not depend on Classy libraries.

These tests exist to facilitate the process of decoupling theme from Classy. The decoupling process includes replacing the use of all Classy libraries with theme-specific ones. These tests ensure these replacements are properly implemented.

@group Theme

Hierarchy

Expanded class hierarchy of ThemeNotUsingClassyLibraryTest

File

core/tests/Drupal/KernelTests/Core/Theme/ThemeNotUsingClassyLibraryTest.php, line 17

Namespace

Drupal\KernelTests\Core\Theme
View source
class ThemeNotUsingClassyLibraryTest extends KernelTestBase {

  /**
   * The theme initialization.
   *
   * @var \Drupal\Core\Theme\ThemeInitializationInterface
   */
  protected $themeInitialization;

  /**
   * The library discovery service.
   *
   * @var \Drupal\Core\Asset\LibraryDiscoveryInterface
   */
  protected $libraryDiscovery;

  /**
   * The theme handler.
   *
   * @var \Drupal\Core\Extension\ThemeHandlerInterface
   */
  protected $themeHandler;

  /**
   * Classy's libraries.
   *
   * These are the libraries defined in classy.libraries.yml.
   *
   * @var string[][]
   *
   * @see \Drupal\Core\Asset\LibraryDiscoveryInterface::getLibrariesByExtension()
   */
  protected $classyLibraries;

  /**
   * Libraries that Classy extends.
   *
   * These are the libraries listed in `libraries-extend` in classy.info.yml.
   *
   * @var string[][]
   */
  protected $classyLibrariesExtend;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->themeInitialization = $this->container
      ->get('theme.initialization');
    $this->libraryDiscovery = $this->container
      ->get('library.discovery');
    $this->themeHandler = $this->container
      ->get('theme_handler');
    $this->container
      ->get('theme_installer')
      ->install([
      'umami',
      'bartik',
      'seven',
      'claro',
    ]);
    $this->classyLibraries = $this->libraryDiscovery
      ->getLibrariesByExtension('classy');
    $this
      ->assertNotEmpty($this->classyLibraries);
    $this->classyLibrariesExtend = $this->themeHandler
      ->getTheme('classy')->info['libraries-extend'];
    $this
      ->assertNotEmpty($this->classyLibrariesExtend);
  }

  /**
   * Ensures that a theme is decoupled from Classy libraries.
   *
   * This confirms that none of the libraries defined in classy.libraries.yml
   * are loaded by the current theme. For this to happen, the current theme
   * must override the Classy library so no assets from Classy are loaded.
   *
   * @param string $theme
   *   The theme being tested.
   * @param string[] $libraries_to_skip
   *   Libraries excluded from the test.
   *
   * @dataProvider providerTestThemeNotUsingClassyLibraries
   */
  public function testThemeNotUsingClassyLibraries($theme, array $libraries_to_skip) {

    // In some cases an overridden Classy library does not use any copied assets
    // from Classy. This array collects those so this test knows to skip
    // assertions specific to those copied assets.
    $skip_asset_matching_assertions = [];
    $theme_path = $this->themeHandler
      ->getTheme($theme)
      ->getPath();

    // A list of all libraries that the current theme is overriding. In a
    // theme's info.yml file, these are the libraries listed in
    // `libraries-override:`, and are libraries altered by the current theme.
    // This will be used for confirming that all of Classy's libraries are
    // overridden.
    $theme_library_overrides = $this->themeInitialization
      ->getActiveThemeByName($theme)
      ->getLibrariesOverride()[$theme_path] ?? [];

    // A list of all libraries created by the current theme.
    $theme_libraries = $this->libraryDiscovery
      ->getLibrariesByExtension($theme);
    $this
      ->assertNotEmpty($theme_libraries);

    // Loop through all libraries overridden by the theme. For those that are
    // Classy libraries, confirm that the overrides prevent the loading of any
    // Classy asset.
    foreach ($theme_library_overrides as $library_name => $library_definition) {
      $in_skip_list = in_array(str_replace('classy/', '', $library_name), $libraries_to_skip);

      // If the library name does not begin with `classy/`, it's not a Classy
      // library.
      $not_classy_library = substr($library_name, 0, 7) !== 'classy/';

      // If $library_definition is false or a string, the override is preventing
      // the Classy library from loading altogether.
      $library_fully_replaced = $library_definition === FALSE || gettype($library_definition) === 'string';

      // If the library is fully replaced, it may need to be added to the
      // $skip_asset_matching_assertions array.
      if ($library_fully_replaced) {

        // Libraries with names that begin with `$theme/classy.` are copies of
        // Classy libraries.
        $not_copied_from_classy = gettype($library_definition) === 'string' && substr($library_definition, 0, 8 + strlen($theme)) !== "{$theme}/classy.";

        // If the overridden library is not copied from Classy or is FALSE (i.e.
        // not loaded at all), it is customized and should skip the tests that
        // check for a 1:1 asset match between the Classy library and its
        // override in the current theme.
        if ($library_definition === FALSE || $not_copied_from_classy) {
          $skip_asset_matching_assertions[] = $library_name;
        }
      }

      // If any of these three conditions are true, there's no need for the
      // remaining asset-specific assertions in this loop.
      if ($in_skip_list || $not_classy_library || $library_fully_replaced) {
        continue;
      }

      // If the library override has a 'css' key, some Classy CSS files may
      // still be loading. Confirm this is not the case.
      if (isset($library_definition['css'])) {
        $this
          ->confirmNoClassyAssets($library_name, $library_definition, 'css');

        // If the override has no JS and all Classy CSS is accounted for, add it
        // to the list of libraries already fully overridden. It won't be
        // necessary to copy the library from Classy.
        if (!isset($library_definition['js'])) {
          $skip_asset_matching_assertions[] = $library_name;
        }
      }
      if (isset($library_definition['js'])) {
        $this
          ->confirmNoClassyAssets($library_name, $library_definition, 'js');

        // CSS has already been checked. So, if all JS in the library is
        // accounted for, add it to the list of libraries already fully
        // overridden. It won't be necessary to copy the library from Classy.
        $skip_asset_matching_assertions[] = $library_name;
      }
    }

    // Confirm that every Classy library is copied or fully overridden by the
    // current theme.
    foreach ($this->classyLibraries as $classy_library_name => $classy_library) {

      // If a Classy library is in the $skip_asset_matching_assertions
      // array, it does not use any assets copied from Classy and can skip the
      // tests in this loop.
      $fully_overridden = in_array("classy/{$classy_library_name}", $skip_asset_matching_assertions);
      $skip = in_array($classy_library_name, $libraries_to_skip);
      if ($skip || $fully_overridden) {
        continue;
      }

      // Confirm the Classy Library is overridden so assets aren't loaded twice.
      $this
        ->assertArrayHasKey("classy/{$classy_library_name}", $theme_library_overrides, "The classy/{$classy_library_name} library is not overridden in {$theme}");

      // Confirm there is a theme-specific version of the Classy library.
      $this
        ->assertArrayHasKey("classy.{$classy_library_name}", $theme_libraries, "There is not a {$theme} equivalent for classy/{$classy_library_name}");
      $theme_copy_of_classy_library = $theme_libraries["classy.{$classy_library_name}"];

      // If the Classy library includes CSS, confirm the theme's copy has the
      // same CSS with the same properties.
      if (!empty($classy_library['css'])) {
        $this
          ->confirmMatchingAssets($classy_library_name, $classy_library, $theme_copy_of_classy_library, $theme_path, 'css');
      }

      // If the Classy library includes JavaScript, confirm the theme's copy has
      // the same JavaScript with the same properties.
      if (!empty($classy_library['js'])) {
        $this
          ->confirmMatchingAssets($classy_library_name, $classy_library, $theme_copy_of_classy_library, $theme_path, 'js');
      }
    }
  }

  /**
   * Checks for theme-specific equivalents of all Classy library-extends.
   *
   * Classy extends several core libraries with its own assets, these are
   * defined in the `libraries-extend:` list in classy.info.yml. Classy adds
   * additional assets to these libraries (e.g. when the `file/drupal.file`
   * library loads, the assets of `classy/file` are loaded as well). For a theme
   * to be properly decoupled from Classy's libraries, these core library
   * extensions must become the responsibility of that theme.
   *
   * @param string $theme
   *   The theme being tested.
   * @param string[] $extends_to_skip
   *   Classy library-extends excluded from the test.
   *
   * @dataProvider providerTestThemeAccountsForClassyExtensions
   */
  public function testThemeAccountsForClassyExtensions($theme, array $extends_to_skip) {
    $theme_path = $this->themeHandler
      ->getTheme($theme)
      ->getPath();

    // Get a list of libraries overridden by the current theme. In a theme's
    // info.yml file, these are the libraries listed in `libraries-override:`.
    // They are libraries altered by the current theme.
    $theme_library_overrides = $this->themeInitialization
      ->getActiveThemeByName($theme)
      ->getLibrariesOverride()[$theme_path] ?? [];

    // Get a list of libraries extended by the current theme. In a theme's
    // info.yml file, these are the libraries listed in `libraries-extend:`.
    // The current theme adds additional files to these libraries.
    $theme_extends = $this->themeHandler
      ->getTheme($theme)->info['libraries-extend'] ?? [];

    // Some Classy libraries extend core libraries (i.e. they are not standalone
    // libraries. Rather, they extend the functionality of existing core
    // libraries). These extensions that were implemented in Classy need to be
    // accounted for in the current theme by either 1) The current theme
    // extending the core library with local copy of the Classy library 2)
    // Overriding the core library altogether.
    // The following iterates through each library extended by Classy to confirm
    // that the current theme accounts for these these extensions.
    foreach ($this->classyLibrariesExtend as $library_extended => $info) {
      if (in_array($library_extended, $extends_to_skip)) {
        continue;
      }
      $extends_core_library = isset($theme_extends[$library_extended]);
      $overrides_core_library = isset($theme_library_overrides[$library_extended]);

      // Every core library extended by Classy must be extended or overridden by
      // the current theme.
      $this
        ->assertTrue($extends_core_library || $overrides_core_library, "{$library_extended} is extended by Classy and should be extended or overridden by {$theme}");

      // If the core library is overridden, confirm that the override does not
      // include any Classy assets.
      if ($overrides_core_library) {
        $overridden_with = $theme_library_overrides[$library_extended];

        // A library override variable can be one of three types:
        // - bool (set to false): this means the override simply prevents the
        //   library from loading.
        // - array: this means some files in the overridden library are changed,
        //   but not necessarily all of them.
        // - string (which is what is being looked for here): this means the
        //   library is replaced with a completely different library.
        $override_replaces_library = gettype($overridden_with) === 'string';
        if ($override_replaces_library) {

          // Make sure the replacement library does not come from Classy.
          $this
            ->assertFalse(substr($overridden_with, 0, 7) === 'classy/', "{$library_extended} is replaced with {$overridden_with}. The replacement should not be a Classy library.");
        }

        // If the override doesn't prevent the core library from loading
        // entirely, and it doesn't replace it with another library, each asset
        // must be checked to confirm it isn't coming from Classy.
        if ($overridden_with !== FALSE && !$override_replaces_library) {
          foreach ([
            'component',
            'layout',
          ] as $category) {
            if (isset($overridden_with['css'][$category])) {
              foreach ($overridden_with['css'][$category] as $css_file) {
                $this
                  ->assertFalse(strpos($css_file, 'core/themes/classy/css'), "Override is loading a Classy asset: {$css_file}");
              }
            }
          }
          if (isset($overridden_with['js'])) {
            foreach ($overridden_with['js'] as $js_file) {
              $this
                ->assertFalse(strpos($js_file, 'core/themes/classy/js'), "Override is loading a Classy asset: {$js_file}");
            }
          }
        }
      }

      // If the library is extended, make sure it's not being extended with a
      // Classy library.
      if ($extends_core_library) {
        foreach ($theme_extends[$library_extended] as $library) {
          $this
            ->assertFalse(substr($library, 0, 7) === 'classy/', "{$theme} is extending the core library: {$library_extended} with {$library}. Core libraries should not be extended with a Classy library.");
        }
      }
    }
  }

  /**
   * Confirms a library is not loading any Classy assets.
   *
   * @param string $library_name
   *   The library name.
   * @param string[][] $library_definition
   *   The data for a library, as defined in a theme's `.libraries.yml` file.
   * @param string $type
   *   The type of asset, either 'js' or 'css'.
   */
  protected function confirmNoClassyAssets($library_name, array $library_definition, $type) {

    // Get the Classy version of the library being overridden.
    $classy_library = $this->classyLibraries[str_replace('classy/', '', $library_name)];

    // Get a list of all CSS or JS files loaded by the Classy library.
    $files_used_in_classy_library = array_map(function ($item) {
      return str_replace('core/themes/classy/', '', $item['data']);
    }, $classy_library[$type]);
    $files_used_by_library_override = [];
    if ($type === 'js') {
      foreach ($library_definition[$type] as $js_file => $options) {
        $files_used_by_library_override[] = $js_file;
      }
    }
    elseif ($type === 'css') {
      foreach ([
        'component',
        'layout',
      ] as $category) {
        if (isset($library_definition[$type][$category])) {
          foreach ($library_definition[$type][$category] as $css_file => $options) {
            $files_used_by_library_override[] = $css_file;
          }
        }
      }
    }
    $classy_files_still_loading = array_diff($files_used_in_classy_library, $files_used_by_library_override);
    $this
      ->assertEmpty($classy_files_still_loading, "{$library_name} is overridden, but the theme is still loading these files from Classy. " . print_r($classy_files_still_loading, 1));
  }

  /**
   * Confirms that the assets of a copied Classy library match the original's.
   *
   * @param string $classy_library_name
   *   The name of the Classy library.
   * @param array[] $classy_library_data
   *   The Classy library's data.
   * @param array[] $theme_copy_of_classy_library
   *   The theme's copy of the Classy library.
   * @param string $theme_path
   *   The path to the current theme.
   * @param string $type
   *   The asset type, either 'js' or 'css'.
   */
  protected function confirmMatchingAssets($classy_library_name, array $classy_library_data, array $theme_copy_of_classy_library, $theme_path, $type) {
    $this
      ->assertArrayHasKey($type, $theme_copy_of_classy_library);
    $theme_assets = [];
    $classy_assets = [];

    // Create arrays of Classy and copied assets with a structure that
    // facilitates easy comparison.
    foreach ($theme_copy_of_classy_library[$type] as $item) {
      $key = str_replace("{$theme_path}/{$type}/classy/", '', $item['data']);
      $theme_assets[$key] = $item;

      // Remove the data key as it's the only one that shouldn't match.
      unset($theme_assets[$key]['data']);
    }
    foreach ($classy_library_data[$type] as $item) {
      $key = str_replace("core/themes/classy/{$type}/", '', $item['data']);
      $classy_assets[$key] = $item;

      // Remove the data key as it's the only one that shouldn't match.
      unset($classy_assets[$key]['data']);
    }
    $this
      ->assertNotEmpty($theme_assets);
    $this
      ->assertNotEmpty($classy_assets);
    $this
      ->assertEmpty(array_diff_key($theme_assets, $classy_assets), "Missing the inclusion of one or more files from classy/{$classy_library_name}.");

    // Confirm the properties of each copied file are identical.
    foreach ($classy_assets as $file => $properties) {
      foreach ($properties as $property => $value) {
        $this
          ->assertEqual($theme_assets[$file][$property], $value, "The copied file: {$file} from classy/{$classy_library_name} has a non-matching property: {$property}");
      }
    }
  }

  /**
   * Data provider.
   *
   * The to-skip arrays should become increasingly smaller as issues that
   * remove Classy library dependencies are completed.
   *
   * @return array[]
   *   Themes and the libraries to be ignored.
   */
  public function providerTestThemeNotUsingClassyLibraries() {
    return [
      'claro' => [
        'theme-name' => 'claro',
        'to-skip' => [],
      ],
      'umami' => [
        'theme-name' => 'umami',
        'to-skip' => [],
      ],
      'bartik' => [
        'theme-name' => 'bartik',
        'to-skip' => [],
      ],
      'seven' => [
        'theme-name' => 'seven',
        'to-skip' => [],
      ],
    ];
  }

  /**
   * Data provider.
   *
   * The to-skip arrays should become increasingly smaller as issues that
   * remove Classy library dependencies are completed.
   *
   * @return array[]
   *   Themes and the extensions to be ignored.
   */
  public function providerTestThemeAccountsForClassyExtensions() {
    return [
      [
        'theme-name' => 'claro',
        'to-skip' => [],
      ],
      [
        'theme-name' => 'umami',
        'to-skip' => [],
      ],
      [
        'theme-name' => 'bartik',
        'to-skip' => [],
      ],
      [
        'theme-name' => 'seven',
        'to-skip' => [],
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssertContentTrait::$content protected property The current raw content.
AssertContentTrait::$drupalSettings protected property The drupalSettings value from the current raw $content.
AssertContentTrait::$elements protected property The XML structure parsed from the current raw $content. 1
AssertContentTrait::$plainTextContent protected property The plain-text content of raw $content (text nodes).
AssertContentTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertContentTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertContentTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertContentTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertContentTrait::assertLink protected function Passes if a link with the specified label is found.
AssertContentTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertContentTrait::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
AssertContentTrait::assertNoEscaped protected function Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertNoField protected function Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertContentTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertContentTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertContentTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertContentTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertContentTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertContentTrait::assertNoLinkByHrefInMainRegion protected function Passes if a link containing a given href is not found in the main region.
AssertContentTrait::assertNoOption protected function Asserts that a select option in the current page does not exist.
AssertContentTrait::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
AssertContentTrait::assertNoPattern protected function Triggers a pass if the perl regex pattern is not found in raw content.
AssertContentTrait::assertNoRaw protected function Passes if the raw text is NOT found on the loaded page, fail otherwise.
AssertContentTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text.
AssertContentTrait::assertNoTitle protected function Pass if the page title is not the given string.
AssertContentTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertContentTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertContentTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionSelectedWithDrupalSelector protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionWithDrupalSelector protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertContentTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise.
AssertContentTrait::assertText protected function Passes if the page (with HTML stripped) contains the text.
AssertContentTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern protected function Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertThemeOutput protected function Asserts themed output.
AssertContentTrait::assertTitle protected function Pass if the page title is the given string.
AssertContentTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertContentTrait::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
AssertContentTrait::buildXPathQuery protected function Builds an XPath query.
AssertContentTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertContentTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
AssertContentTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertContentTrait::getDrupalSettings protected function Gets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::getRawContent protected function Gets the current raw content.
AssertContentTrait::getSelectedItem protected function Get the selected value from a select field.
AssertContentTrait::getTextContent protected function Retrieves the plain-text content from the current raw content.
AssertContentTrait::getUrl protected function Get the current URL from the cURL handler. 1
AssertContentTrait::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
AssertContentTrait::removeWhiteSpace protected function Removes all white-space between HTML tags from the raw content.
AssertContentTrait::setDrupalSettings protected function Sets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::setRawContent protected function Sets the raw content (e.g. HTML).
AssertContentTrait::xpath protected function Performs an xpath search on the contents of the internal browser.
AssertHelperTrait::castSafeStrings protected static function Casts MarkupInterface objects into strings.
AssertLegacyTrait::assert protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::assertEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead.
AssertLegacyTrait::assertIdenticalObject protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertNotEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead.
AssertLegacyTrait::assertNotIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead.
AssertLegacyTrait::pass protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::verbose protected function
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
KernelTestBase::$backupGlobals protected property Back up and restore any global variables that may be changed by tests.
KernelTestBase::$backupStaticAttributes protected property Back up and restore static class properties that may be changed by tests.
KernelTestBase::$backupStaticAttributesBlacklist protected property Contains a few static class properties for performance.
KernelTestBase::$classLoader protected property
KernelTestBase::$configImporter protected property @todo Move into Config test base class. 7
KernelTestBase::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking.
KernelTestBase::$container protected property
KernelTestBase::$databasePrefix protected property
KernelTestBase::$modules protected static property Modules to enable. 464
KernelTestBase::$preserveGlobalState protected property Do not forward any global state from the parent process to the processes that run the actual tests.
KernelTestBase::$root protected property The app root.
KernelTestBase::$runTestInSeparateProcess protected property Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property.
KernelTestBase::$siteDirectory protected property
KernelTestBase::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 6
KernelTestBase::$vfsRoot protected property The virtual filesystem root directory.
KernelTestBase::assertPostConditions protected function 1
KernelTestBase::bootEnvironment protected function Bootstraps a basic test environment.
KernelTestBase::bootKernel private function Bootstraps a kernel for a test.
KernelTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
KernelTestBase::disableModules protected function Disables modules for this test.
KernelTestBase::enableModules protected function Enables modules for this test.
KernelTestBase::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
KernelTestBase::getDatabaseConnectionInfo protected function Returns the Database connection info to be used for this test. 1
KernelTestBase::getDatabasePrefix public function
KernelTestBase::getExtensionsForModules private function Returns Extension objects for $modules to enable.
KernelTestBase::getModulesToEnable private static function Returns the modules to enable for this test.
KernelTestBase::initFileCache protected function Initializes the FileCache component.
KernelTestBase::installConfig protected function Installs default configuration for a given list of modules.
KernelTestBase::installEntitySchema protected function Installs the storage schema for a specific entity type.
KernelTestBase::installSchema protected function Installs database tables from a module schema definition.
KernelTestBase::isTestInIsolation Deprecated protected function Returns whether the current test method is running in a separate process.
KernelTestBase::prepareTemplate protected function
KernelTestBase::register public function Registers test-specific services. Overrides ServiceProviderInterface::register 26
KernelTestBase::render protected function Renders a render array. 1
KernelTestBase::setInstallProfile protected function Sets the install profile and rebuilds the container to update it.
KernelTestBase::setSetting protected function Sets an in-memory Settings variable.
KernelTestBase::setUpBeforeClass public static function 1
KernelTestBase::setUpFilesystem protected function Sets up the filesystem, so things like the file directory. 2
KernelTestBase::stop protected function Stops test execution.
KernelTestBase::tearDown protected function 6
KernelTestBase::tearDownCloseDatabaseConnection public function @after
KernelTestBase::vfsDump protected function Dumps the current state of the virtual filesystem to STDOUT.
KernelTestBase::__get Deprecated public function BC: Automatically resolve former KernelTestBase class properties.
KernelTestBase::__sleep public function Prevents serializing any properties.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
RandomGeneratorTrait::$randomGenerator protected property The random generator.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers. 1
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestRequirementsTrait::checkModuleRequirements private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements protected function Check module requirements for the Drupal use case. 1
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
ThemeNotUsingClassyLibraryTest::$classyLibraries protected property Classy's libraries.
ThemeNotUsingClassyLibraryTest::$classyLibrariesExtend protected property Libraries that Classy extends.
ThemeNotUsingClassyLibraryTest::$libraryDiscovery protected property The library discovery service.
ThemeNotUsingClassyLibraryTest::$themeHandler protected property The theme handler.
ThemeNotUsingClassyLibraryTest::$themeInitialization protected property The theme initialization.
ThemeNotUsingClassyLibraryTest::confirmMatchingAssets protected function Confirms that the assets of a copied Classy library match the original's.
ThemeNotUsingClassyLibraryTest::confirmNoClassyAssets protected function Confirms a library is not loading any Classy assets.
ThemeNotUsingClassyLibraryTest::providerTestThemeAccountsForClassyExtensions public function Data provider.
ThemeNotUsingClassyLibraryTest::providerTestThemeNotUsingClassyLibraries public function Data provider.
ThemeNotUsingClassyLibraryTest::setUp protected function Overrides KernelTestBase::setUp
ThemeNotUsingClassyLibraryTest::testThemeAccountsForClassyExtensions public function Checks for theme-specific equivalents of all Classy library-extends.
ThemeNotUsingClassyLibraryTest::testThemeNotUsingClassyLibraries public function Ensures that a theme is decoupled from Classy libraries.