You are here

public function DefaultPluginManagerTest::testCreateInstanceWithInvalidInterfaces in Zircon Profile 8

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

Tests plugins without the proper interface.

@covers ::createInstance

@expectedException \Drupal\Component\Plugin\Exception\PluginException @expectedExceptionMessage Plugin "kale" (Drupal\plugin_test\Plugin\plugin_test\fruit\Kale) must implement interface \Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface

File

core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php, line 256
Contains \Drupal\Tests\Core\Plugin\DefaultPluginManagerTest.

Class

DefaultPluginManagerTest
Tests the DefaultPluginManager.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCreateInstanceWithInvalidInterfaces() {
  $module_handler = $this
    ->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $module_handler
    ->expects($this
    ->any())
    ->method('moduleExists')
    ->with('plugin_test')
    ->willReturn(TRUE);
  $this->expectedDefinitions['kale'] = array(
    '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, '\\Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\FruitInterface');
  $plugin_manager
    ->createInstance('kale');
}