/** * @covers ::buildSelectorForm * @covers ::setSelectablePluginType */ public function testBuildSelectorForm() { $this->sut->setSelectablePluginType($this->selectablePluginType); $form = []; $form_state = new FormState(); $form = $this->sut->buildSelectorForm($form, $form_state); $this->assertInternalType('array', $form); }
/** * {@inheritdoc} */ public function buildSelectorForm(array $form, FormStateInterface $form_state) { $form = parent::buildSelectorForm($form, $form_state); $available_plugins = []; $cacheability_metadata = CacheableMetadata::createFromRenderArray($form); foreach (array_keys($this->selectablePluginDiscovery->getDefinitions()) as $plugin_id) { $available_plugin = $this->selectablePluginFactory->createInstance($plugin_id); $available_plugins[] = $available_plugin; $cacheability_metadata = $cacheability_metadata->merge(CacheableMetadata::createFromObject($available_plugin)); } $cacheability_metadata->applyTo($form); $plugin_selector_form_state_key = static::setPluginSelector($form_state, $this); $form['container'] = array('#attributes' => array('class' => array('plugin-selector-' . Html::getClass($this->getPluginId()))), '#available_plugins' => $available_plugins, '#plugin_selector_form_state_key' => $plugin_selector_form_state_key, '#process' => [[get_class(), 'processBuildSelectorForm']], '#tree' => TRUE, '#type' => 'container'); return $form; }