You are here

public function WebformElementPluginPropertiesTest::testElementDefaultProperties in Webform 8.5

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

Test element default properties.

File

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

Class

WebformElementPluginPropertiesTest
Tests for webform element properties.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testElementDefaultProperties() {

  // Comparing all element's expected and actual default properties ensures
  // that there are not unexpected changes to any element's
  // default properties.
  $expected_elements = $this
    ->getExpectedElementDefaultProperties();

  // Issue #3110478: [Webform 8.x-6.x] Track the D9 readiness state of the
  // Webform module's (optional) dependencies.
  // @see https://www.drupal.org/project/webform/issues/3110478
  unset($expected_elements['webform_entity_print_attachment:pdf']);
  $actual_elements = $this
    ->getActualElementDefaultProperties();
  $this
    ->htmlOutput('<pre>' . htmlentities(Yaml::encode($actual_elements)) . '</pre>');
  foreach ($actual_elements as $element_key => $actual_element) {
    if ($expected_elements[$element_key] !== $actual_element) {
      $this
        ->htmlOutput('<pre>' . Yaml::encode([
        $element_key => $actual_element,
      ]) . '</pre>');
    }
    $this
      ->assertEquals($expected_elements[$element_key], $actual_element, "Expected and actual '{$element_key}' element properties match.");
  }
}