class ThemeInstallerTest

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest
  2. 10 core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest
  3. 11.x core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest

Tests installing and uninstalling of themes.

@group Extension

Hierarchy

Expanded class hierarchy of ThemeInstallerTest

File

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

Namespace

Drupal\KernelTests\Core\Theme
View source
class ThemeInstallerTest extends KernelTestBase {
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'system',
    ];
    
    /**
     * {@inheritdoc}
     */
    public function register(ContainerBuilder $container) {
        parent::register($container);
        // Some test methods involve ModuleHandler operations, which attempt to
        // rebuild and dump routes.
        $container->register('router.dumper', 'Drupal\\Core\\Routing\\NullMatcherDumper');
    }
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->installConfig([
            'system',
        ]);
    }
    
    /**
     * Verifies that no themes are installed by default.
     */
    public function testEmpty() {
        $this->assertEmpty($this->extensionConfig()
            ->get('theme'));
        $this->assertEmpty(array_keys($this->themeHandler()
            ->listInfo()));
        $this->assertEmpty(array_keys(\Drupal::service('theme_handler')->listInfo()));
        // Rebuilding available themes should always yield results though.
        $this->assertNotEmpty($this->themeHandler()
            ->rebuildThemeData()['stark'], 'ThemeHandler::rebuildThemeData() yields all available themes.');
        // theme_get_setting() should return global default theme settings.
        $this->assertTrue(theme_get_setting('features.favicon'));
    }
    
    /**
     * Tests installing a theme.
     */
    public function testInstall() {
        $name = 'test_basetheme';
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertFalse(isset($themes[$name]));
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $this->assertSame(0, $this->extensionConfig()
            ->get("theme.{$name}"));
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertEquals($name, $themes[$name]->getName());
        // Verify that test_basetheme.settings is active.
        $this->assertFalse(theme_get_setting('features.favicon', $name));
        $this->assertEquals('only', theme_get_setting('base', $name));
        $this->assertEquals('base', theme_get_setting('override', $name));
    }
    
    /**
     * Tests installing a sub-theme.
     */
    public function testInstallSubTheme() {
        $name = 'test_subtheme';
        $base_name = 'test_basetheme';
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertEmpty(array_keys($themes));
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertTrue(isset($themes[$base_name]));
        $this->themeInstaller()
            ->uninstall([
            $name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertFalse(isset($themes[$name]));
        $this->assertTrue(isset($themes[$base_name]));
    }
    
    /**
     * Tests installing a non-existing theme.
     */
    public function testInstallNonExisting() {
        $name = 'non_existing_theme';
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertEmpty(array_keys($themes));
        try {
            $message = 'ThemeInstaller::install() throws UnknownExtensionException upon installing a non-existing theme.';
            $this->themeInstaller()
                ->install([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(UnknownExtensionException::class, $e);
        }
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertEmpty(array_keys($themes));
    }
    
    /**
     * Tests installing a theme with a too long name.
     */
    public function testInstallNameTooLong() {
        $name = 'test_theme_having_veery_long_name_which_is_too_long';
        try {
            $message = 'ThemeInstaller::install() throws ExtensionNameLengthException upon installing a theme with a too long name.';
            $this->themeInstaller()
                ->install([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(ExtensionNameLengthException::class, $e);
        }
    }
    
    /**
     * Tests installing a theme with unmet module dependencies.
     *
     * @dataProvider providerTestInstallThemeWithUnmetModuleDependencies
     */
    public function testInstallThemeWithUnmetModuleDependencies($theme_name, $installed_modules, $message) {
        $this->container
            ->get('module_installer')
            ->install($installed_modules);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertEmpty($themes);
        $this->expectException(MissingDependencyException::class);
        $this->expectExceptionMessage($message);
        $this->themeInstaller()
            ->install([
            $theme_name,
        ]);
    }
    
    /**
     * Tests trying to install a deprecated theme.
     *
     * @covers ::install
     *
     * @group legacy
     */
    public function testInstallDeprecated() {
        $this->expectDeprecation("The theme 'deprecated_theme_test' is deprecated. See https://example.com/deprecated");
        $this->themeInstaller()
            ->install([
            'deprecated_theme_test',
        ]);
        $this->assertTrue(\Drupal::service('theme_handler')->themeExists('deprecated_theme_test'));
    }
    
    /**
     * Data provider for testInstallThemeWithUnmetModuleDependencies().
     */
    public function providerTestInstallThemeWithUnmetModuleDependencies() {
        return [
            'theme with uninstalled module dependencies' => [
                'test_theme_depending_on_modules',
                [],
                "Unable to install theme: 'test_theme_depending_on_modules' due to unmet module dependencies: 'test_module_required_by_theme, test_another_module_required_by_theme'.",
            ],
            'theme with a base theme with uninstalled module dependencies' => [
                'test_theme_with_a_base_theme_depending_on_modules',
                [],
                "Unable to install theme: 'test_theme_with_a_base_theme_depending_on_modules' due to unmet module dependencies: 'test_module_required_by_theme, test_another_module_required_by_theme'.",
            ],
            'theme and base theme have uninstalled module dependencies' => [
                'test_theme_mixed_module_dependencies',
                [],
                "Unable to install theme: 'test_theme_mixed_module_dependencies' due to unmet module dependencies: 'help, test_module_required_by_theme, test_another_module_required_by_theme'.",
            ],
            'theme with already installed module dependencies, base theme module dependencies are not installed' => [
                'test_theme_mixed_module_dependencies',
                [
                    'help',
                ],
                "Unable to install theme: 'test_theme_mixed_module_dependencies' due to unmet module dependencies: 'test_module_required_by_theme, test_another_module_required_by_theme'.",
            ],
            'theme with module dependencies not installed, base theme module dependencies are already installed, ' => [
                'test_theme_mixed_module_dependencies',
                [
                    'test_module_required_by_theme',
                    'test_another_module_required_by_theme',
                ],
                "Unable to install theme: 'test_theme_mixed_module_dependencies' due to unmet module dependencies: 'help'.",
            ],
            'theme depending on a module that does not exist' => [
                'test_theme_depending_on_nonexisting_module',
                [],
                "Unable to install theme: 'test_theme_depending_on_nonexisting_module' due to unmet module dependencies: 'test_module_non_existing",
            ],
            'theme depending on an installed but incompatible module' => [
                'test_theme_depending_on_constrained_modules',
                [
                    'test_module_compatible_constraint',
                    'test_module_incompatible_constraint',
                ],
                "Unable to install theme: Test Module Theme Depends on with Incompatible Constraint (>=8.x-2.x) (incompatible with version 8.x-1.8)",
            ],
        ];
    }
    
    /**
     * Tests installing a theme with module dependencies that are met.
     */
    public function testInstallThemeWithMetModuleDependencies() {
        $name = 'test_theme_depending_on_modules';
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertArrayNotHasKey($name, $themes);
        $this->container
            ->get('module_installer')
            ->install([
            'test_module_required_by_theme',
            'test_another_module_required_by_theme',
        ]);
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertArrayHasKey($name, $themes);
        $this->expectException(ModuleUninstallValidatorException::class);
        $this->expectExceptionMessage('The following reasons prevent the modules from being uninstalled: Required by the theme: Test Theme Depending on Modules');
        $this->container
            ->get('module_installer')
            ->uninstall([
            'test_module_required_by_theme',
        ]);
    }
    
    /**
     * Tests uninstalling the default theme.
     */
    public function testUninstallDefault() {
        $name = 'stark';
        $other_name = 'olivero';
        $this->themeInstaller()
            ->install([
            $name,
            $other_name,
        ]);
        $this->config('system.theme')
            ->set('default', $name)
            ->save();
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertTrue(isset($themes[$other_name]));
        try {
            $message = 'ThemeInstaller::uninstall() throws InvalidArgumentException upon disabling default theme.';
            $this->themeInstaller()
                ->uninstall([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(\InvalidArgumentException::class, $e);
        }
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertTrue(isset($themes[$other_name]));
    }
    
    /**
     * Tests uninstalling the admin theme.
     */
    public function testUninstallAdmin() {
        $name = 'stark';
        $other_name = 'olivero';
        $this->themeInstaller()
            ->install([
            $name,
            $other_name,
        ]);
        $this->config('system.theme')
            ->set('admin', $name)
            ->save();
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertTrue(isset($themes[$other_name]));
        try {
            $message = 'ThemeInstaller::uninstall() throws InvalidArgumentException upon disabling admin theme.';
            $this->themeInstaller()
                ->uninstall([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(\InvalidArgumentException::class, $e);
        }
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertTrue(isset($themes[$other_name]));
    }
    
    /**
     * Tests uninstalling a sub-theme.
     */
    public function testUninstallSubTheme() {
        $name = 'test_subtheme';
        $base_name = 'test_basetheme';
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $this->themeInstaller()
            ->uninstall([
            $name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertFalse(isset($themes[$name]));
        $this->assertTrue(isset($themes[$base_name]));
    }
    
    /**
     * Tests uninstalling a base theme before its sub-theme.
     */
    public function testUninstallBaseBeforeSubTheme() {
        $name = 'test_basetheme';
        $sub_name = 'test_subtheme';
        $this->themeInstaller()
            ->install([
            $sub_name,
        ]);
        try {
            $message = 'ThemeInstaller::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.';
            $this->themeInstaller()
                ->uninstall([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(\InvalidArgumentException::class, $e);
        }
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertTrue(isset($themes[$sub_name]));
        // Verify that uninstalling both at the same time works.
        $this->themeInstaller()
            ->uninstall([
            $name,
            $sub_name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertFalse(isset($themes[$name]));
        $this->assertFalse(isset($themes[$sub_name]));
    }
    
    /**
     * Tests uninstalling a non-existing theme.
     */
    public function testUninstallNonExisting() {
        $name = 'non_existing_theme';
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertEmpty(array_keys($themes));
        try {
            $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.';
            $this->themeInstaller()
                ->uninstall([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(UnknownExtensionException::class, $e);
        }
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertEmpty(array_keys($themes));
    }
    
    /**
     * Tests uninstalling a theme.
     */
    public function testUninstall() {
        $name = 'test_basetheme';
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $this->assertNotEmpty($this->config("{$name}.settings")
            ->get());
        $this->themeInstaller()
            ->uninstall([
            $name,
        ]);
        $this->assertEmpty(array_keys($this->themeHandler()
            ->listInfo()));
        $this->assertEmpty($this->config("{$name}.settings")
            ->get());
        // Ensure that the uninstalled theme can be installed again.
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]));
        $this->assertEquals($name, $themes[$name]->getName());
        $this->assertNotEmpty($this->config("{$name}.settings")
            ->get());
    }
    
    /**
     * Tests uninstalling a theme that is not installed.
     */
    public function testUninstallNotInstalled() {
        $name = 'test_basetheme';
        try {
            $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.';
            $this->themeInstaller()
                ->uninstall([
                $name,
            ]);
            $this->fail($message);
        } catch (\Exception $e) {
            $this->assertInstanceOf(UnknownExtensionException::class, $e);
        }
    }
    
    /**
     * Tests that theme info can be altered by a module.
     *
     * @see module_test_system_info_alter()
     */
    public function testThemeInfoAlter() {
        $name = 'stark';
        $this->container
            ->get('state')
            ->set('module_test.hook_system_info_alter', TRUE);
        $this->themeInstaller()
            ->install([
            $name,
        ]);
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertFalse(isset($themes[$name]->info['regions']['test_region']));
        // Install module_test.
        $this->moduleInstaller()
            ->install([
            'module_test',
        ], FALSE);
        $this->assertTrue($this->moduleHandler()
            ->moduleExists('module_test'));
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertTrue(isset($themes[$name]->info['regions']['test_region']));
        // Legacy assertions.
        // @todo Remove once theme initialization/info has been modernized.
        // @see https://www.drupal.org/node/2228093
        $info = \Drupal::service('extension.list.theme')->getExtensionInfo($name);
        $this->assertTrue(isset($info['regions']['test_region']));
        $regions = system_region_list($name);
        $this->assertTrue(isset($regions['test_region']));
        $theme_list = \Drupal::service('theme_handler')->listInfo();
        $this->assertTrue(isset($theme_list[$name]->info['regions']['test_region']));
        $this->moduleInstaller()
            ->uninstall([
            'module_test',
        ]);
        $this->assertFalse($this->moduleHandler()
            ->moduleExists('module_test'));
        $themes = $this->themeHandler()
            ->listInfo();
        $this->assertFalse(isset($themes[$name]->info['regions']['test_region']));
        // Legacy assertions.
        // @todo Remove once theme initialization/info has been modernized.
        // @see https://www.drupal.org/node/2228093
        $info = \Drupal::service('extension.list.theme')->getExtensionInfo($name);
        $this->assertFalse(isset($info['regions']['test_region']));
        $regions = system_region_list($name);
        $this->assertFalse(isset($regions['test_region']));
        $theme_list = \Drupal::service('theme_handler')->listInfo();
        $this->assertFalse(isset($theme_list[$name]->info['regions']['test_region']));
    }
    
    /**
     * Returns the theme handler service.
     *
     * @return \Drupal\Core\Extension\ThemeHandlerInterface
     */
    protected function themeHandler() {
        return $this->container
            ->get('theme_handler');
    }
    
    /**
     * Returns the theme installer service.
     *
     * @return \Drupal\Core\Extension\ThemeInstallerInterface
     */
    protected function themeInstaller() {
        return $this->container
            ->get('theme_installer');
    }
    
    /**
     * Returns the system.theme config object.
     *
     * @return \Drupal\Core\Config\Config
     */
    protected function extensionConfig() {
        return $this->config('core.extension');
    }
    
    /**
     * Returns the ModuleHandler.
     *
     * @return \Drupal\Core\Extension\ModuleHandlerInterface
     */
    protected function moduleHandler() {
        return $this->container
            ->get('module_handler');
    }
    
    /**
     * Returns the ModuleInstaller.
     *
     * @return \Drupal\Core\Extension\ModuleInstallerInterface
     */
    protected function moduleInstaller() {
        return $this->container
            ->get('module_installer');
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title 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 raw text IS NOT found escaped on 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.
AssertLegacyTrait::assert Deprecated protected function
AssertLegacyTrait::assertEqual Deprecated protected function
AssertLegacyTrait::assertIdentical Deprecated protected function
AssertLegacyTrait::assertIdenticalObject Deprecated protected function
AssertLegacyTrait::assertNotEqual Deprecated protected function
AssertLegacyTrait::assertNotIdentical Deprecated protected function
AssertLegacyTrait::pass Deprecated protected function
AssertLegacyTrait::verbose Deprecated 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.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
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. 6
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::$keyValue protected property The key_value service that must persist between container rebuilds.
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. 7
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. 3
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::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. 3
KernelTestBase::stop protected function Stops test execution.
KernelTestBase::tearDown protected function 5
KernelTestBase::tearDownCloseDatabaseConnection public function @after
KernelTestBase::vfsDump protected function Dumps the current state of the virtual filesystem to STDOUT.
KernelTestBase::__sleep public function Prevents serializing any properties.
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
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.
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
ThemeInstallerTest::$modules protected static property Modules to enable. Overrides KernelTestBase::$modules
ThemeInstallerTest::extensionConfig protected function Returns the system.theme config object.
ThemeInstallerTest::moduleHandler protected function Returns the ModuleHandler.
ThemeInstallerTest::moduleInstaller protected function Returns the ModuleInstaller.
ThemeInstallerTest::providerTestInstallThemeWithUnmetModuleDependencies public function Data provider for testInstallThemeWithUnmetModuleDependencies().
ThemeInstallerTest::register public function Registers test-specific services. Overrides KernelTestBase::register
ThemeInstallerTest::setUp protected function Overrides KernelTestBase::setUp
ThemeInstallerTest::testEmpty public function Verifies that no themes are installed by default.
ThemeInstallerTest::testInstall public function Tests installing a theme.
ThemeInstallerTest::testInstallDeprecated public function Tests trying to install a deprecated theme.
ThemeInstallerTest::testInstallNameTooLong public function Tests installing a theme with a too long name.
ThemeInstallerTest::testInstallNonExisting public function Tests installing a non-existing theme.
ThemeInstallerTest::testInstallSubTheme public function Tests installing a sub-theme.
ThemeInstallerTest::testInstallThemeWithMetModuleDependencies public function Tests installing a theme with module dependencies that are met.
ThemeInstallerTest::testInstallThemeWithUnmetModuleDependencies public function Tests installing a theme with unmet module dependencies.
ThemeInstallerTest::testThemeInfoAlter public function Tests that theme info can be altered by a module.
ThemeInstallerTest::testUninstall public function Tests uninstalling a theme.
ThemeInstallerTest::testUninstallAdmin public function Tests uninstalling the admin theme.
ThemeInstallerTest::testUninstallBaseBeforeSubTheme public function Tests uninstalling a base theme before its sub-theme.
ThemeInstallerTest::testUninstallDefault public function Tests uninstalling the default theme.
ThemeInstallerTest::testUninstallNonExisting public function Tests uninstalling a non-existing theme.
ThemeInstallerTest::testUninstallNotInstalled public function Tests uninstalling a theme that is not installed.
ThemeInstallerTest::testUninstallSubTheme public function Tests uninstalling a sub-theme.
ThemeInstallerTest::themeHandler protected function Returns the theme handler service.
ThemeInstallerTest::themeInstaller protected function Returns the theme installer service.

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