MessageTest.php 832 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Drupal\KernelTests\Core\Theme;
  3. use Drupal\KernelTests\KernelTestBase;
  4. /**
  5. * Tests built-in message theme functions.
  6. *
  7. * @group Theme
  8. */
  9. class MessageTest extends KernelTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static $modules = ['system'];
  14. /**
  15. * Tests setting messages output.
  16. */
  17. public function testMessages() {
  18. // Enable the Classy theme.
  19. \Drupal::service('theme_handler')->install(['classy']);
  20. $this->config('system.theme')->set('default', 'classy')->save();
  21. drupal_set_message('An error occurred', 'error');
  22. drupal_set_message('But then something nice happened');
  23. $messages = [
  24. '#type' => 'status_messages',
  25. ];
  26. $this->render($messages);
  27. $this->assertRaw('messages messages--error');
  28. $this->assertRaw('messages messages--status');
  29. }
  30. }