You are here

protected function WebformElementPluginPropertiesTest::getActualElementDefaultProperties in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Element/WebformElementPluginPropertiesTest.php \Drupal\Tests\webform\Functional\Element\WebformElementPluginPropertiesTest::getActualElementDefaultProperties()

Get actual element default properties.

Return value

array Expected element default properties.

1 call to WebformElementPluginPropertiesTest::getActualElementDefaultProperties()
WebformElementPluginPropertiesTest::testElementDefaultProperties in tests/src/Functional/Element/WebformElementPluginPropertiesTest.php
Test element default properties.

File

tests/src/Functional/Element/WebformElementPluginPropertiesTest.php, line 76

Class

WebformElementPluginPropertiesTest
Tests for webform element properties.

Namespace

Drupal\Tests\webform\Functional\Element

Code

protected function getActualElementDefaultProperties() {

  /** @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();
  $properties = [];
  foreach ($webform_elements as $element_key => $webform_element) {
    $default_properties = $webform_element
      ->getDefaultProperties();
    if (!$webform_element
      ->supportsMultipleValues() && isset($default_properties['format_items'])) {
      throw new \Exception("'{$element_key}' does not support multiple value but has '#format_items' property.");
    }
    ksort($default_properties);
    $properties[$webform_element
      ->getPluginId()] = $default_properties;
  }
  ksort($properties);
  WebformElementHelper::convertRenderMarkupToStrings($properties);
  return $properties;
}