ThemeExtensionListTest.php

Same filename in this branch
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/ThemeExtensionListTest.php
Same filename in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ThemeExtensionListTest.php
  2. 9 core/tests/Drupal/Tests/Core/Extension/ThemeExtensionListTest.php
  3. 10 core/tests/Drupal/KernelTests/Core/Extension/ThemeExtensionListTest.php
  4. 10 core/tests/Drupal/Tests/Core/Extension/ThemeExtensionListTest.php
  5. 11.x core/tests/Drupal/KernelTests/Core/Extension/ThemeExtensionListTest.php
  6. 11.x core/tests/Drupal/Tests/Core/Extension/ThemeExtensionListTest.php

Namespace

Drupal\KernelTests\Core\Extension

File

core/tests/Drupal/KernelTests/Core/Extension/ThemeExtensionListTest.php

View source
<?php

namespace Drupal\KernelTests\Core\Extension;

use Drupal\Core\Site\Settings;
use Drupal\KernelTests\KernelTestBase;

/**
 * @coversDefaultClass \Drupal\Core\Extension\ThemeExtensionList
 * @group Extension
 */
class ThemeExtensionListTest extends KernelTestBase {
    
    /**
     * @covers ::getList
     */
    public function testGetlist() {
        $settings = Settings::getAll();
        $settings['install_profile'] = 'testing';
        new Settings($settings);
        \Drupal::configFactory()->getEditable('core.extension')
            ->set('module.testing', 1000)
            ->set('theme.test_theme', 0)
            ->save();
        // The installation profile is provided by a container parameter.
        // Saving the configuration doesn't automatically trigger invalidation
        $this->container
            ->get('kernel')
            ->rebuildContainer();
        
        /** @var \Drupal\Core\Extension\ThemeExtensionList $theme_extension_list */
        $theme_extension_list = \Drupal::service('extension.list.theme');
        $extensions = $theme_extension_list->getList();
        $this->assertArrayHasKey('test_theme', $extensions);
    }
    
    /**
     * Tests that themes have an empty default version set.
     */
    public function testThemeWithoutVersion() {
        $theme = \Drupal::service('extension.list.theme')->get('test_theme_settings_features');
        $this->assertNull($theme->info['version']);
    }

}

Classes

Title Deprecated Summary
ThemeExtensionListTest @coversDefaultClass \Drupal\Core\Extension\ThemeExtensionList @group Extension

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