You are here

protected function JsMessageTest::assertCurrentMessages in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Core/JsMessageTest.php \Drupal\FunctionalJavascriptTests\Core\JsMessageTest::assertCurrentMessages()

Asserts that currently shown messages match expected messages.

Parameters

array $expected_messages: Expected messages.

string $messagesSelector: The css selector for the containing messages element.

1 call to JsMessageTest::assertCurrentMessages()
JsMessageTest::testAddRemoveMessages in core/tests/Drupal/FunctionalJavascriptTests/Core/JsMessageTest.php
Test click on links to show messages and remove messages.

File

core/tests/Drupal/FunctionalJavascriptTests/Core/JsMessageTest.php, line 112

Class

JsMessageTest
Tests core/drupal.message library.

Namespace

Drupal\FunctionalJavascriptTests\Core

Code

protected function assertCurrentMessages(array $expected_messages, $messagesSelector) {
  $expected_messages = array_values($expected_messages);
  $current_messages = [];
  if ($message_divs = $this
    ->getSession()
    ->getPage()
    ->findAll('css', "{$messagesSelector} .messages")) {
    foreach ($message_divs as $message_div) {

      /** @var \Behat\Mink\Element\NodeElement $message_div */
      $current_messages[] = $message_div
        ->getText();
    }
  }
  $this
    ->assertEquals($expected_messages, $current_messages);
}