public function AdvancedPluginSelectorBaseTest::testBuildPluginForm in Plugin 8.2
@covers ::buildPluginForm
File
- tests/
src/ Unit/ Plugin/ Plugin/ PluginSelector/ AdvancedPluginSelectorBaseTest.php, line 81
Class
- AdvancedPluginSelectorBaseTest
- @coversDefaultClass \Drupal\plugin\Plugin\Plugin\PluginSelector\AdvancedPluginSelectorBase
Namespace
Drupal\Tests\plugin\Unit\Plugin\Plugin\PluginSelectorCode
public function testBuildPluginForm() {
$form_state = $this
->createMock(FormStateInterface::class);
$plugin_form = [
'#foo' => $this
->randomMachineName(),
];
$plugin = $this
->getMockForAbstractClass(AdvancedPluginSelectorBaseUnitTestPluginFormPluginInterface::class);
$plugin
->expects($this
->once())
->method('buildConfigurationForm')
->with([], $form_state)
->willReturn($plugin_form);
$method = new \ReflectionMethod($this->sut, 'buildPluginForm');
$method
->setAccessible(TRUE);
$build = $method
->invoke($this->sut, $form_state);
$this
->assertSame('container', $build['#type']);
$this->sut
->setSelectedPlugin($plugin);
$build = $method
->invoke($this->sut, $form_state);
$this
->assertSame('container', $build['#type']);
$this
->assertSame($plugin_form['#foo'], $build['#foo']);
}