You are here

protected function WebformElementPluginDefinitionsTest::getActualElementDefinitions in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Functional/Element/WebformElementPluginDefinitionsTest.php \Drupal\Tests\webform\Functional\Element\WebformElementPluginDefinitionsTest::getActualElementDefinitions()

Get actual element definitions.

Return value

array Expected element definitions.

1 call to WebformElementPluginDefinitionsTest::getActualElementDefinitions()
WebformElementPluginDefinitionsTest::testElementDefinitions in tests/src/Functional/Element/WebformElementPluginDefinitionsTest.php
Test element definitions.

File

tests/src/Functional/Element/WebformElementPluginDefinitionsTest.php, line 74

Class

WebformElementPluginDefinitionsTest
Tests for webform element definitions.

Namespace

Drupal\Tests\webform\Functional\Element

Code

protected function getActualElementDefinitions() {

  /** @var \Drupal\webform\Plugin\WebformElementManagerInterface $webform_element_manager */
  $webform_element_manager = \Drupal::service('plugin.manager.webform.element');

  /** @var \Drupal\webform\Plugin\WebformElementInterface[] $webform_elements */
  $webform_elements = $webform_element_manager
    ->getInstances();
  $element = [
    '#type' => 'element',
  ];
  $definitions = [];
  foreach ($webform_elements as $element_key => $webform_element) {
    $webform_element_plugin_definition = $webform_element_manager
      ->getDefinition($element_key);
    $definition = $webform_element_plugin_definition + [
      'input' => $webform_element
        ->isInput($element),
      'container' => $webform_element
        ->isContainer($element),
      'composite' => $webform_element
        ->isComposite(),
      'root' => $webform_element
        ->isRoot(),
      'hidden' => $webform_element
        ->isHidden(),
      'multiple' => $webform_element
        ->supportsMultipleValues(),
      'multiline' => $webform_element
        ->isMultiline($element),
    ];
    $definitions[$webform_element
      ->getPluginId()] = $definition;
  }
  ksort($definitions);
  WebformElementHelper::convertRenderMarkupToStrings($definitions);
  return $definitions;
}