MessageTest.php 891 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php

/**
 * @file
 * Contains \Drupal\system\Tests\Theme\MessageTest.
 */

namespace Drupal\system\Tests\Theme;

use Drupal\simpletest\KernelTestBase;

/**
 * Tests built-in message theme functions.
 *
 * @group Theme
 */
class MessageTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = array('system');

  /**
   * Tests setting messages output.
   */
  function testMessages() {
28 29
    // Enable the Classy theme.
    \Drupal::service('theme_handler')->install(['classy']);
30
    \Drupal::service('theme_handler')->setDefault('classy');
31

32 33 34
    drupal_set_message('An error occurred', 'error');
    drupal_set_message('But then something nice happened');
    $messages = array(
35
      '#type' => 'status_messages',
36 37 38 39 40 41
    );
    $this->render($messages);
    $this->assertRaw('messages messages--error');
    $this->assertRaw('messages messages--status');
  }
}