function PluginFormFactoryTest::testCreateInstancePluginAware

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

@covers ::createInstance

File

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

Class

PluginFormFactoryTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21PluginFormFactory.php/class/PluginFormFactory/8.9.x" title="Provides form discovery capabilities for plugins." class="local">\Drupal\Core\Plugin\PluginFormFactory</a> @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

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

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