function PluginFormFactoryTest::testCreateInstanceDefinitionException

Tests create instance definition exception.

@legacy-covers ::createInstance

File

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

Class

PluginFormFactoryTest
Tests Drupal\Core\Plugin\PluginFormFactory.

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCreateInstanceDefinitionException() : void {
  $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->assertNull($form_object);
}

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