You are here

public function PluginFormFactoryTest::testCreateInstanceDefinitionException in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/PluginFormFactoryTest.php \Drupal\Tests\Core\Plugin\PluginFormFactoryTest::testCreateInstanceDefinitionException()
  2. 10 core/tests/Drupal/Tests/Core/Plugin/PluginFormFactoryTest.php \Drupal\Tests\Core\Plugin\PluginFormFactoryTest::testCreateInstanceDefinitionException()

@covers ::createInstance

File

core/tests/Drupal/Tests/Core/Plugin/PluginFormFactoryTest.php, line 127

Class

PluginFormFactoryTest
@coversDefaultClass \Drupal\Core\Plugin\PluginFormFactory @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCreateInstanceDefinitionException() {
  $this
    ->expectException(InvalidPluginDefinitionException::class);
  $this
    ->expectExceptionMessage('The "the_plugin_id" plugin did not specify a "anything" form class');
  $plugin = $this
    ->prophesize(PluginWithFormsInterface::class);
  $plugin
    ->getPluginId()
    ->willReturn('the_plugin_id');
  $plugin
    ->hasFormClass('anything')
    ->willReturn(FALSE);
  $form_object = $this->manager
    ->createInstance($plugin
    ->reveal(), 'anything');
  $this
    ->assertSame(NULL, $form_object);
}