function DrupalMessengerServiceTest::testDrupalMessengerService

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php \Drupal\Tests\system\Functional\Bootstrap\DrupalMessengerServiceTest::testDrupalMessengerService()
  2. 10 core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php \Drupal\Tests\system\Functional\Bootstrap\DrupalMessengerServiceTest::testDrupalMessengerService()
  3. 11.x core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php \Drupal\Tests\system\Functional\Bootstrap\DrupalMessengerServiceTest::testDrupalMessengerService()

Tests Messenger service.

File

core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php, line 30

Class

DrupalMessengerServiceTest
Tests the Messenger service.

Namespace

Drupal\Tests\system\Functional\Bootstrap

Code

public function testDrupalMessengerService() {
    // The page at system_test.messenger_service route sets two messages and
    // then removes the first before it is displayed.
    $this->drupalGet(Url::fromRoute('system_test.messenger_service'));
    $this->assertNoText('First message (removed).');
    $this->assertRaw(t('Second message with <em>markup!</em> (not removed).'));
    // Ensure duplicate messages are handled as expected.
    $this->assertUniqueText('Non Duplicated message');
    $this->assertNoUniqueText('Duplicated message');
    // Ensure Markup objects are rendered as expected.
    $this->assertRaw('Markup with <em>markup!</em>');
    $this->assertUniqueText('Markup with markup!');
    $this->assertRaw('Markup2 with <em>markup!</em>');
    // Ensure when the same message is of different types it is not duplicated.
    $this->assertUniqueText('Non duplicate Markup / string.');
    $this->assertNoUniqueText('Duplicate Markup / string.');
    // Ensure that strings that are not marked as safe are escaped.
    $this->assertEscaped('<em>This<span>markup will be</span> escaped</em>.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.