You are here

public function PluginFormFactoryTest::testCreateInstance 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::testCreateInstance()

@covers ::createInstance

File

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

Class

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

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCreateInstance() {
  $plugin_form = $this
    ->prophesize(PluginFormInterface::class);
  $expected = $plugin_form
    ->reveal();
  $this->classResolver
    ->getInstanceFromDefinition(get_class($expected))
    ->willReturn($expected);
  $plugin = $this
    ->prophesize(PluginWithFormsInterface::class);
  $plugin
    ->hasFormClass('standard_class')
    ->willReturn(TRUE);
  $plugin
    ->getFormClass('standard_class')
    ->willReturn(get_class($expected));
  $form_object = $this->manager
    ->createInstance($plugin
    ->reveal(), 'standard_class');
  $this
    ->assertSame($expected, $form_object);
}