function DefaultPluginManagerTest::testGetDefinitionsWithoutRequiredInterface

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

Tests plugins without a required interface.

@covers ::getDefinitions

File

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

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testGetDefinitionsWithoutRequiredInterface() : void {
    $module_handler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $module_handler->expects($this->any())
        ->method('moduleExists')
        ->with('plugin_test')
        ->willReturn(FALSE);
    $this->expectedDefinitions['kale'] = [
        'id' => 'kale',
        'label' => 'Kale',
        'color' => 'green',
        'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Kale',
        'provider' => 'plugin_test',
    ];
    $this->expectedDefinitions['apple']['provider'] = 'plugin_test';
    $this->expectedDefinitions['banana']['provider'] = 'plugin_test';
    $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler, NULL);
    $this->assertIsArray($plugin_manager->getDefinitions());
}

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