/**
  * @covers ::buildSelectorForm
  * @covers ::setPluginSelector
  */
 public function testBuildSelectorFormWithMultipleAvailablePlugins()
 {
     $form = [];
     $form_state = $this->getMock(FormStateInterface::class);
     $cache_contexts = [$this->randomMachineName()];
     $cache_tags = [$this->randomMachineName()];
     $plugin_id_a = $this->randomMachineName();
     $plugin_a = $this->getMock(PluginInspectionInterface::class);
     $plugin_id_b = $this->randomMachineName();
     $plugin_b = $this->getMock(AdvancedPluginSelectorBaseUnitTestPluginFormPluginInterface::class);
     $this->configureMockCacheableDependency($plugin_b, $cache_contexts, mt_rand(), $cache_tags);
     $plugin_definitions = [$plugin_id_a => ['id' => $plugin_id_a], $plugin_id_b => ['id' => $plugin_id_b]];
     $map = [[$plugin_id_a, [], $plugin_a], [$plugin_id_b, [], $plugin_b]];
     $this->selectablePluginManager->expects($this->atLeastOnce())->method('createInstance')->willReturnMap($map);
     $this->selectablePluginManager->expects($this->any())->method('getDefinitions')->willReturn($plugin_definitions);
     $build = $this->sut->buildSelectorForm($form, $form_state);
     unset($build['container']['#plugin_selector_form_state_key']);
     $expected_build = array('#cache' => ['contexts' => $cache_contexts, 'tags' => $cache_tags, 'max-age' => 0], 'container' => array('#attributes' => array('class' => array('plugin-selector-' . Html::getId($this->pluginId))), '#available_plugins' => array($plugin_a, $plugin_b), '#process' => [[AdvancedPluginSelectorBase::class, 'processBuildSelectorForm']], '#tree' => TRUE, '#type' => 'container'));
     $this->assertSame($expected_build, $build);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function buildSelectorForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildSelectorForm($form, $form_state);
     $form['clear'] = array('#markup' => '<div style="clear: both;"></div>');
     return $form;
 }