You are here

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

@covers ::createInstance

File

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

Class

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

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCreateInstanceDefaultFallback() {
  $this->classResolver
    ->getInstanceFromDefinition(Argument::cetera())
    ->shouldNotBeCalled();
  $plugin = $this
    ->prophesize(PluginWithFormsInterface::class)
    ->willImplement(PluginFormInterface::class);
  $plugin
    ->hasFormClass('missing')
    ->willReturn(FALSE);
  $plugin
    ->hasFormClass('fallback')
    ->willReturn(TRUE);
  $plugin
    ->getFormClass('fallback')
    ->willReturn(get_class($plugin
    ->reveal()));
  $form_object = $this->manager
    ->createInstance($plugin
    ->reveal(), 'missing', 'fallback');
  $this
    ->assertSame($plugin
    ->reveal(), $form_object);
}