public function SystemTestController::drupalSetMessageTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::drupalSetMessageTest()
Tests setting messages and removing one before it is displayed.
Return value
string Empty string, we just test the setting of messages.
1 string reference to 'SystemTestController::drupalSetMessageTest'
- system_test.routing.yml in core/
modules/ system/ tests/ modules/ system_test/ system_test.routing.yml - core/modules/system/tests/modules/system_test/system_test.routing.yml
File
- core/
modules/ system/ tests/ modules/ system_test/ src/ Controller/ SystemTestController.php, line 103 - Contains \Drupal\system_test\Controller\SystemTestController.
Class
- SystemTestController
- Controller routines for system_test routes.
Namespace
Drupal\system_test\ControllerCode
public function drupalSetMessageTest() {
// Set two messages.
drupal_set_message('First message (removed).');
drupal_set_message(t('Second message with <em>markup!</em> (not removed).'));
// Remove the first.
unset($_SESSION['messages']['status'][0]);
// Duplicate message check.
drupal_set_message('Non Duplicated message', 'status', FALSE);
drupal_set_message('Non Duplicated message', 'status', FALSE);
drupal_set_message('Duplicated message', 'status', TRUE);
drupal_set_message('Duplicated message', 'status', TRUE);
// Add a Markup message.
drupal_set_message(Markup::create('Markup with <em>markup!</em>'));
// Test duplicate Markup messages.
drupal_set_message(Markup::create('Markup with <em>markup!</em>'));
// Ensure that multiple Markup messages work.
drupal_set_message(Markup::create('Markup2 with <em>markup!</em>'));
// Test mixing of types.
drupal_set_message(Markup::create('Non duplicate Markup / string.'));
drupal_set_message('Non duplicate Markup / string.');
drupal_set_message(Markup::create('Duplicate Markup / string.'), 'status', TRUE);
drupal_set_message('Duplicate Markup / string.', 'status', TRUE);
// Test auto-escape of non safe strings.
drupal_set_message('<em>This<span>markup will be</span> escaped</em>.');
return [];
}