function DefaultPluginManagerTest::testDefaultPluginManagerWithDisabledModule

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testDefaultPluginManagerWithDisabledModule()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testDefaultPluginManagerWithDisabledModule()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testDefaultPluginManagerWithDisabledModule()

Tests the plugin manager with a disabled module.

File

core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php, line 92

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testDefaultPluginManagerWithDisabledModule() : void {
  $definitions = $this->expectedDefinitions;
  $definitions['cherry'] = [
    'id' => 'cherry',
    'label' => 'Cherry',
    'color' => 'red',
    'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Cherry',
    'provider' => 'disabled_module',
  ];
  $module_handler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $module_handler->expects($this->once())
    ->method('moduleExists')
    ->with('disabled_module')
    ->willReturn(FALSE);
  $plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler, 'test_alter_hook', '\\Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\FruitInterface');
  $this->assertEmpty($plugin_manager->getDefinition('cherry', FALSE), 'Plugin information of a disabled module is not available');
}

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