You are here

public function WebformElementPluginDefinitionsTest::testElementDefinitions in Webform 6.x

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

Test element definitions.

File

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

Class

WebformElementPluginDefinitionsTest
Tests for webform element definitions.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testElementDefinitions() {

  // Comparing all element's expected and actual definitions ensures
  // that there are not unexpected changes to any element's definitions.
  $expected_definitions = $this
    ->getExpectedElementDefinitions();

  // 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_definitions['webform_entity_print_attachment:pdf']);
  $actual_definitions = $this
    ->getActualElementDefinitions();
  $this
    ->htmlOutput('<pre>' . htmlentities(Yaml::encode($actual_definitions)) . '</pre>');
  foreach ($actual_definitions as $key => $actual_definition) {
    if ($expected_definitions[$key] !== $actual_definition) {
      $this
        ->htmlOutput('<pre>' . Yaml::encode([
        $key => $actual_definition,
      ]) . '</pre>');
    }
    $this
      ->assertEquals($expected_definitions[$key], $actual_definition, "Expected and actual '{$key}' element definitions match.");
  }
}