trait DeprecatedModulesTestTrait

Provides methods remove deprecated modules from tests.

Hierarchy

12 files declare their use of DeprecatedModulesTestTrait
DestinationCategoryTest.php in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php
FieldTypePluginManagerTest.php in core/modules/field/tests/src/Kernel/FieldTypePluginManagerTest.php
HelpTopicsSyntaxTest.php in core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php
MigrateDrupal6AuditIdsTest.php in core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php
MigrateDrupal7AuditIdsTest.php in core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php

... See full list

File

core/tests/Drupal/Tests/DeprecatedModulesTestTrait.php, line 8

Namespace

Drupal\Tests
View source
trait DeprecatedModulesTestTrait {
    
    /**
     * List of deprecated modules names to not be enabled for tests.
     *
     * @var array
     */
    protected $deprecatedModules = [
        'block_place',
    ];
    
    /**
     * Flag to exclude deprecated modules from the tests.
     *
     * Legacy*Test -test may set this to FALSE to include also deprecated
     * modules for tests.
     *
     * @var bool
     */
    protected $excludeDeprecated = TRUE;
    
    /**
     * Removes deprecated modules from the provided modules.list.
     *
     * @param array $modules
     *   Array of modules names.
     *
     * @return array
     *   The filtered $modules array.
     */
    protected function removeDeprecatedModules(array $modules) {
        return $this->excludeDeprecated ? array_diff($modules, $this->deprecatedModules) : $modules;
    }
    
    /**
     * Overrides \Drupal\KernelTests\KernelTestBase::enableModules().
     *
     * For kernel tests this override will ensure that deprecated modules are not
     * enabled if \Drupal\Tests\DeprecatedModulesTestTrait::$excludeDeprecated
     * is set to true.
     */
    protected function enableModules(array $modules) {
        parent::enableModules($this->removeDeprecatedModules($modules));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
DeprecatedModulesTestTrait::$deprecatedModules protected property List of deprecated modules names to not be enabled for tests.
DeprecatedModulesTestTrait::$excludeDeprecated protected property Flag to exclude deprecated modules from the tests. 12
DeprecatedModulesTestTrait::enableModules protected function Overrides \Drupal\KernelTests\KernelTestBase::enableModules().
DeprecatedModulesTestTrait::removeDeprecatedModules protected function Removes deprecated modules from the provided modules.list.

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