function DefaultFactoryTest::testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDefinition

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php \Drupal\Tests\Component\Plugin\DefaultFactoryTest::testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDefinition()
  2. 10 core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php \Drupal\Tests\Component\Plugin\DefaultFactoryTest::testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDefinition()
  3. 11.x core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php \Drupal\Tests\Component\Plugin\DefaultFactoryTest::testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDefinition()

Tests getPluginClass() with a required interface but no implementation.

@covers ::getPluginClass

File

core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php, line 130

Class

DefaultFactoryTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Plugin%21Factory%21DefaultFactory.php/class/DefaultFactory/8.9.x" title="Default plugin factory." class="local">\Drupal\Component\Plugin\Factory\DefaultFactory</a> @group Plugin

Namespace

Drupal\Tests\Component\Plugin

Code

public function testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDefinition() {
    $this->expectException(PluginException::class);
    $this->expectExceptionMessage('Plugin "corn" (Drupal\\Tests\\Component\\Plugin\\Fixtures\\vegetable\\Broccoli) must implement interface Drupal\\Tests\\Component\\Plugin\\Fixtures\\vegetable\\VegetableInterface.');
    DefaultFactory::getPluginClass('corn', [
        'class' => Broccoli::class,
    ], VegetableInterface::class);
}

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