function PluginFormFactoryTest::testCreateInstanceDefinitionException

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/PluginFormFactoryTest.php \Drupal\Tests\Core\Plugin\PluginFormFactoryTest::testCreateInstanceDefinitionException()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/PluginFormFactoryTest.php \Drupal\Tests\Core\Plugin\PluginFormFactoryTest::testCreateInstanceDefinitionException()
  3. 11.x 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 129

Class

PluginFormFactoryTest
@coversDefaultClass \Drupal\Core\Plugin\PluginFormFactory[[api-linebreak]] @group Plugin

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.