You are here

function MessageTest::testMessages in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/MessageTest.php \Drupal\system\Tests\Theme\MessageTest::testMessages()

Tests setting messages output.

File

core/modules/system/src/Tests/Theme/MessageTest.php, line 27
Contains \Drupal\system\Tests\Theme\MessageTest.

Class

MessageTest
Tests built-in message theme functions.

Namespace

Drupal\system\Tests\Theme

Code

function testMessages() {

  // Enable the Classy theme.
  \Drupal::service('theme_handler')
    ->install([
    'classy',
  ]);
  $this
    ->config('system.theme')
    ->set('default', 'classy')
    ->save();
  drupal_set_message('An error occurred', 'error');
  drupal_set_message('But then something nice happened');
  $messages = array(
    '#type' => 'status_messages',
  );
  $this
    ->render($messages);
  $this
    ->assertRaw('messages messages--error');
  $this
    ->assertRaw('messages messages--status');
}