trait DeprecatedModulesTestTrait in Drupal 8
Provides methods remove deprecated modules from tests.
Hierarchy
- trait \Drupal\Tests\DeprecatedModulesTestTrait
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
File
- core/
tests/ Drupal/ Tests/ DeprecatedModulesTestTrait.php, line 8
Namespace
Drupal\TestsView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeprecatedModulesTestTrait:: |
protected | property | List of deprecated modules names to not be enabled for tests. | |
DeprecatedModulesTestTrait:: |
protected | property | Flag to exclude deprecated modules from the tests. | 12 |
DeprecatedModulesTestTrait:: |
protected | function | Overrides \Drupal\KernelTests\KernelTestBase::enableModules(). | |
DeprecatedModulesTestTrait:: |
protected | function | Removes deprecated modules from the provided modules.list. |