function ModuleExtensionListTest::testGetlist

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php \Drupal\KernelTests\Core\Extension\ModuleExtensionListTest::testGetlist()
  2. 10 core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php \Drupal\KernelTests\Core\Extension\ModuleExtensionListTest::testGetList()
  3. 11.x core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php \Drupal\KernelTests\Core\Extension\ModuleExtensionListTest::testGetList()

@covers ::getList

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleExtensionListTest.php, line 16

Class

ModuleExtensionListTest
@coversDefaultClass \Drupal\Core\Extension\ModuleExtensionList @group Extension

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testGetlist() {
    \Drupal::configFactory()->getEditable('core.extension')
        ->set('module.testing', 1000)
        ->set('profile', 'testing')
        ->save();
    // The installation profile is provided by a container parameter.
    // Saving the configuration doesn't automatically trigger invalidation
    $this->container
        ->get('kernel')
        ->rebuildContainer();
    
    /** @var \Drupal\Core\Extension\ModuleExtensionList $module_extension_list */
    $module_extension_list = \Drupal::service('extension.list.module');
    $extensions = $module_extension_list->getList();
    $this->assertArrayHasKey('testing', $extensions);
    $this->assertEquals(1000, $extensions['testing']->weight);
}

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