示例#1
0
 /**
  * The basic functionality of retrieving enabled modules.
  */
 function testModuleList()
 {
     // Build a list of modules, sorted alphabetically.
     $profile_info = install_profile_info('testing', 'en');
     $module_list = $profile_info['dependencies'];
     // Installation profile is a module that is expected to be loaded.
     $module_list[] = 'testing';
     sort($module_list);
     // Compare this list to the one returned by the module handler. We expect
     // them to match, since all default profile modules have a weight equal to 0
     // (except for block.module, which has a lower weight but comes first in
     // the alphabet anyway).
     $this->assertModuleList($module_list, 'Testing profile');
     // Try to install a new module.
     $this->moduleHandler()->install(array('ban'));
     $module_list[] = 'ban';
     sort($module_list);
     $this->assertModuleList($module_list, 'After adding a module');
     // Try to mess with the module weights.
     module_set_weight('ban', 20);
     // Move ban to the end of the array.
     unset($module_list[array_search('ban', $module_list)]);
     $module_list[] = 'ban';
     $this->assertModuleList($module_list, 'After changing weights');
     // Test the fixed list feature.
     $fixed_list = array('system' => 'core/modules/system/system.module', 'menu' => 'core/modules/menu/menu.module');
     $this->moduleHandler()->setModuleList($fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
     $this->assertModuleList($new_module_list, t('When using a fixed list'));
 }
示例#2
0
 /**
  * The basic functionality of retrieving enabled modules.
  */
 function testModuleList()
 {
     // Prime the drupal_get_filename() static cache with the location of the
     // testing profile as it is not the currently active profile and we don't
     // yet have any cached way to retrieve its location.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
     // Build a list of modules, sorted alphabetically.
     $profile_info = install_profile_info('testing', 'en');
     $module_list = $profile_info['dependencies'];
     // Installation profile is a module that is expected to be loaded.
     $module_list[] = 'testing';
     sort($module_list);
     // Compare this list to the one returned by the module handler. We expect
     // them to match, since all default profile modules have a weight equal to 0
     // (except for block.module, which has a lower weight but comes first in
     // the alphabet anyway).
     $this->assertModuleList($module_list, 'Testing profile');
     // Try to install a new module.
     $this->moduleInstaller()->install(array('ban'));
     $module_list[] = 'ban';
     sort($module_list);
     $this->assertModuleList($module_list, 'After adding a module');
     // Try to mess with the module weights.
     module_set_weight('ban', 20);
     // Move ban to the end of the array.
     unset($module_list[array_search('ban', $module_list)]);
     $module_list[] = 'ban';
     $this->assertModuleList($module_list, 'After changing weights');
     // Test the fixed list feature.
     $fixed_list = array('system' => 'core/modules/system/system.module', 'menu' => 'core/modules/menu/menu.module');
     $this->moduleHandler()->setModuleList($fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
     $this->assertModuleList($new_module_list, t('When using a fixed list'));
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('menu_link_content');
     // Ensure that the weight of module_link_content is higher than system.
     // @see menu_link_content_install()
     module_set_weight('menu_link_content', 1);
 }
 /**
  * The basic functionality of retrieving enabled modules.
  */
 function testModuleList()
 {
     $module_list = ['system'];
     $this->assertModuleList($module_list, 'Initial');
     // Try to install a new module.
     $this->moduleInstaller()->install(array('ban'));
     $module_list[] = 'ban';
     sort($module_list);
     $this->assertModuleList($module_list, 'After adding a module');
     // Try to mess with the module weights.
     module_set_weight('ban', 20);
     // Move ban to the end of the array.
     unset($module_list[array_search('ban', $module_list)]);
     $module_list[] = 'ban';
     $this->assertModuleList($module_list, 'After changing weights');
     // Test the fixed list feature.
     $fixed_list = array('system' => 'core/modules/system/system.module', 'menu' => 'core/modules/menu/menu.module');
     $this->moduleHandler()->setModuleList($fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
     $this->assertModuleList($new_module_list, t('When using a fixed list'));
 }
 /**
  * Tests that the module list is retained after enabling/installing/disabling.
  */
 function testEnableModulesFixedList()
 {
     // Install system module.
     $this->container->get('module_installer')->install(array('system', 'menu_link_content'));
     $entity_manager = \Drupal::entityManager();
     // entity_test is loaded via $modules; its entity type should exist.
     $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
     // Load some additional modules; entity_test should still exist.
     $this->enableModules(array('field', 'text', 'entity_test'));
     $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
     // Install some other modules; entity_test should still exist.
     $this->container->get('module_installer')->install(array('user', 'field', 'field_test'), FALSE);
     $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
     // Uninstall one of those modules; entity_test should still exist.
     $this->container->get('module_installer')->uninstall(array('field_test'));
     $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
     // Set the weight of a module; entity_test should still exist.
     module_set_weight('field', -1);
     $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == $entity_manager->getDefinition('entity_test'));
     // Reactivate the previously uninstalled module.
     $this->enableModules(array('field_test'));
     // Create a field.
     entity_create('entity_view_display', array('targetEntityType' => 'entity_test', 'bundle' => 'entity_test', 'mode' => 'default'));
     $field_storage = entity_create('field_storage_config', array('field_name' => 'test_field', 'entity_type' => 'entity_test', 'type' => 'test_field'));
     $field_storage->save();
     entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => 'entity_test'))->save();
 }