public function PluginFormFactoryTest::testCreateInstanceInvalidException in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Plugin/PluginFormFactoryTest.php \Drupal\Tests\Core\Plugin\PluginFormFactoryTest::testCreateInstanceInvalidException()
@covers ::createInstance
File
- core/
tests/ Drupal/ Tests/ Core/ Plugin/ PluginFormFactoryTest.php, line 142
Class
- PluginFormFactoryTest
- @coversDefaultClass \Drupal\Core\Plugin\PluginFormFactory @group Plugin
Namespace
Drupal\Tests\Core\PluginCode
public function testCreateInstanceInvalidException() {
$this
->expectException(InvalidPluginDefinitionException::class);
$this
->expectExceptionMessage('The "the_plugin_id" plugin did not specify a valid "invalid" form class, must implement \\Drupal\\Core\\Plugin\\PluginFormInterface');
$expected = new \stdClass();
$this->classResolver
->getInstanceFromDefinition(get_class($expected))
->willReturn($expected);
$plugin = $this
->prophesize(PluginWithFormsInterface::class);
$plugin
->getPluginId()
->willReturn('the_plugin_id');
$plugin
->hasFormClass('invalid')
->willReturn(TRUE);
$plugin
->getFormClass('invalid')
->willReturn(get_class($expected));
$form_object = $this->manager
->createInstance($plugin
->reveal(), 'invalid');
$this
->assertSame(NULL, $form_object);
}