You are here

DrupalSetMessageTest.php in Zircon Profile 8.0

File

core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php
View source
<?php

/**
 * @file
 * Contains \Drupal\KernelTests\Core\Common\DrupalSetMessageTest.
 */
namespace Drupal\KernelTests\Core\Common;

use Drupal\KernelTests\KernelTestBase;

/**
 * @covers ::drupal_set_message
 * @group PHPUnit
 */
class DrupalSetMessageTest extends KernelTestBase {

  /**
   * The basic functionality of drupal_set_message().
   */
  public function testDrupalSetMessage() {
    drupal_set_message(t('A message: @foo', [
      '@foo' => 'bar',
    ]));
    $messages = drupal_get_messages();
    $this
      ->assertInstanceOf('Drupal\\Core\\Render\\Markup', $messages['status'][0]);
    $this
      ->assertEquals('A message: bar', (string) $messages['status'][0]);
  }
  public function tearDown() {

    // Clear session to prevent global leakage.
    unset($_SESSION['messages']);
    parent::tearDown();
  }

}

Classes

Namesort descending Description
DrupalSetMessageTest @covers ::drupal_set_message @group PHPUnit