diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php index 8b0ce69..93e10c7 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php @@ -14,6 +14,7 @@ */ class EntityDisplayTest extends DrupalUnitTestBase { + public static $install = array('system', 'entity', 'field'); public static $modules = array('entity_test'); public static function getInfo() { @@ -24,12 +25,6 @@ public static function getInfo() { ); } - protected function setUp() { - parent::setUp(); - - $this->enableModules(array('system', 'entity', 'field')); - } - /** * Tests basic CRUD operations on EntityDisplay objects. */ diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php index c4422aa..b22eb63 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php @@ -15,6 +15,8 @@ class RdfSchemaSerializationTest extends DrupalUnitTestBase { + public static $install = array('system'); + public static function getInfo() { return array( 'name' => 'Site schema JSON-LD serialization', @@ -27,9 +29,6 @@ public static function getInfo() { * Tests the serialization of site schemas. */ function testSchemaSerialization() { - // In order to use url() the url_alias table must be installed, so system - // is enabled. - $this->enableModules(array('system')); $entity_type = $bundle = 'entity_test'; diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php b/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php index e84844b..002072e 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/LanguageTestBase.php @@ -15,11 +15,11 @@ */ abstract class LanguageTestBase extends ViewUnitTestBase { + public static $install = array('system', 'language'); + protected function setUp() { parent::setUp(); - $this->enableModules(array('system', 'language')); - // Create another language beside English. $language = new Language(array('langcode' => 'xx-lolspeak', 'name' => 'Lolspeak')); language_save($language); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 5965410..263c0c2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -50,18 +50,7 @@ */ public static $modules = array(); - /** - * Fixed module list being used by this test. - * - * @var array - * An associative array containing the required data to set the moduleList - * property of the ExtensionHandler. - * - * @see UnitTestBase::setUp() - * @see UnitTestBase::enableModules() - */ - private $moduleList = array(); - + private $extension_handler; private $moduleFiles; private $themeFiles; private $themeData; @@ -104,17 +93,28 @@ protected function setUp() { $this->kernel = new DrupalKernel('testing', TRUE, drupal_classloader(), FALSE); $this->kernel->boot(); - // Ensure that the module list is initially empty. - $this->moduleList = array(); // Collect and set a fixed module list. $class = get_class($this); $modules = array(); + $install = array(); while ($class) { + if (property_exists($class, 'install')) { + $install = array_merge($install, $class::$install); + } if (property_exists($class, 'modules')) { $modules = array_merge($modules, $class::$modules); } $class = get_parent_class($class); } + $system = array_search('system', $install); + if ($system !== FALSE) { + unset($install[$system]); + array_unshift($install, 'system'); + } + $this->extension_handler = $this->container->get('extension_handler'); + if ($install) { + $this->enableModules($install); + } $this->enableModules($modules, FALSE); } @@ -155,8 +155,8 @@ public function containerBuild($container) { ->addArgument(new Reference('service_container')); } // Register an extension handler for managing enabled modules. - $container - ->register('extension_handler', 'Drupal\Core\ExtensionHandlerMinimal'); + $container + ->register('extension_handler', 'Drupal\Core\ExtensionHandlerMinimal'); } /** @@ -202,6 +202,9 @@ protected function installSchema($module, $table) { * enables the new modules in the system.module configuration only, but that * has no effect, since we are operating with a fixed module list. * + * Typically, the $modules static property should be used instead. + * Particularly, 'system' must not be passed to this function manually. + * * @param array $modules * A list of modules to enable. Dependencies are not resolved; i.e., * multiple modules have to be specified with dependent modules first. @@ -215,21 +218,19 @@ protected function installSchema($module, $table) { */ protected function enableModules(array $modules, $install = TRUE) { // Explicitly set the list of modules in the extension handler. - $new_enabled = array(); - $extension_handler = $this->container->get('extension_handler'); + $enabled = $this->extension_handler->getModuleList(); foreach ($modules as $module) { - $this->moduleList[$module] = drupal_get_filename('module', $module); - $this->container->get('extension_handler')->setModuleList($this->moduleList); - + $enabled[$module] = drupal_get_filename('module', $module); // Call module_enable() to enable (install) the new module. if ($install) { module_enable(array($module), FALSE); } + $this->extension_handler->setModuleList($enabled); } // Otherwise, only ensure that the new modules are loaded. if (!$install) { module_load_all(FALSE, TRUE); - $extension_handler->moduleImplementsReset(); + $this->extension_handler->moduleImplementsReset(); } } diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php index 43b807e..59327cf 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php @@ -22,7 +22,7 @@ class AreaTextTest extends ViewUnitTestBase { * @var array */ public static $testViews = array('test_view'); - + public static $install = array('system', 'filter'); public static function getInfo() { return array( 'name' => 'Area: Text', @@ -31,13 +31,6 @@ public static function getInfo() { ); } - protected function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - $this->enableModules(array('filter')); - } - public function testAreaText() { $view = views_get_view('test_view'); $view->setDisplay(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php index 530d53b..e98577f 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php @@ -14,6 +14,8 @@ */ class FieldUrlTest extends ViewUnitTestBase { + public static $install = array('system'); + /** * Views used by this test. * @@ -29,11 +31,6 @@ public static function getInfo() { ); } - public function setup() { - parent::setup(); - $this->enableModules(array('system')); - } - function viewsData() { $data = parent::viewsData(); $data['views_test_data']['name']['field']['id'] = 'url'; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php index f97d581..96102ec 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php @@ -20,7 +20,7 @@ class FilterEqualityTest extends ViewUnitTestBase { * @var array */ public static $testViews = array('test_view'); - + public static $install = array('system', 'menu'); protected $column_map = array( 'views_test_data_name' => 'name', ); @@ -33,13 +33,6 @@ public static function getInfo() { ); } - protected function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - $this->enableModules(array('menu')); - } - function viewsData() { $data = parent::viewsData(); $data['views_test_data']['name']['filter']['id'] = 'equality'; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php index d0ea700..adf33ac 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php @@ -20,7 +20,7 @@ class FilterInOperatorTest extends ViewUnitTestBase { * @var array */ public static $testViews = array('test_view'); - + public static $install = array('system', 'menu'); protected $column_map = array( 'views_test_data_name' => 'name', 'views_test_data_age' => 'age', @@ -34,13 +34,6 @@ public static function getInfo() { ); } - protected function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - $this->enableModules(array('menu')); - } - function viewsData() { $data = parent::viewsData(); $data['views_test_data']['age']['filter']['id'] = 'in_operator'; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php index 8343b7f..5985cd6 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php @@ -20,7 +20,7 @@ class FilterNumericTest extends ViewUnitTestBase { * @var array */ public static $testViews = array('test_view'); - + public static $install = array('system', 'menu'); protected $column_map = array( 'views_test_data_name' => 'name', 'views_test_data_age' => 'age', @@ -34,13 +34,6 @@ public static function getInfo() { ); } - protected function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - $this->enableModules(array('menu')); - } - function viewsData() { $data = parent::viewsData(); $data['views_test_data']['age']['filter']['allow empty'] = TRUE; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php index f6963ce..e7479b7 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php @@ -20,7 +20,7 @@ class FilterStringTest extends ViewUnitTestBase { * @var array */ public static $testViews = array('test_view'); - + public static $install = array('system', 'menu'); protected $column_map = array( 'views_test_data_name' => 'name', ); @@ -33,13 +33,6 @@ public static function getInfo() { ); } - protected function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - $this->enableModules(array('menu')); - } - function viewsData() { $data = parent::viewsData(); $data['views_test_data']['name']['filter']['allow empty'] = TRUE; diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php index c0db658..b837d58 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php @@ -12,6 +12,8 @@ */ class StyleMappingTest extends StyleTestBase { + public static $install = array('system'); + /** * Views used by this test. * @@ -27,12 +29,6 @@ public static function getInfo() { ); } - public function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - } - /** * Verifies that the fields were mapped correctly. */ diff --git a/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php b/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php index c3c24b1..b573145 100644 --- a/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php @@ -12,6 +12,8 @@ */ class TokenReplaceTest extends ViewUnitTestBase { + public static $install = array('system'); + /** * Views used by this test. * @@ -27,12 +29,6 @@ public static function getInfo() { ); } - public function setUp() { - parent::setUp(); - - $this->enableModules(array('system')); - } - /** * Tests core token replacements generated from a view. */