You are here

public function DefaultPluginManagerTest::testDefaultPluginManagerWithObjects in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest::testDefaultPluginManagerWithObjects()

Tests the plugin manager and object plugin definitions.

File

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

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testDefaultPluginManagerWithObjects() {
  $definitions = $this->expectedDefinitions;
  $definitions['cherry'] = (object) [
    '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 is available');
}