You are here

public function DefaultPluginManagerTest::testDefaultPluginManagerWithDisabledModule in Drupal 9

Same name and namespace in other branches
  1. 8 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 88

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testDefaultPluginManagerWithDisabledModule() {
  $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')
    ->will($this
    ->returnValue(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');
}