You are here

private function MessageTemplateUiTest::verifyFormElements in Message 8

Verifying the form elements values in easy way.

When all the elements are passing a pass message with the text "The expected values is in the form." When one of the Xpath expression return false the message will be display on screen.

[
  XPATH_EXPRESSION => MESSAGE,
];

Parameters

array $elements: Array mapped by in the next format.

1 call to MessageTemplateUiTest::verifyFormElements()
MessageTemplateUiTest::testMessageTemplateTranslate in tests/src/Functional/MessageTemplateUiTest.php
Test the translation interface for message templates.

File

tests/src/Functional/MessageTemplateUiTest.php, line 171

Class

MessageTemplateUiTest
Testing the CRUD functionality for the Message template entity.

Namespace

Drupal\Tests\message\Functional

Code

private function verifyFormElements(array $elements) {
  $errors = [];
  foreach ($elements as $xpath => $message) {
    $element = $this
      ->xpath($xpath);
    if (!$element) {
      $errors[] = $message;
    }
  }
  if (empty($errors)) {
    $this
      ->pass('All elements were found.');
  }
  else {
    $this
      ->fail('The next errors were found: ' . implode("", $errors));
  }
}