diff --git a/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php new file mode 100644 index 0000000..78d6c08 --- /dev/null +++ b/core/modules/system/src/Tests/Bootstrap/DrupalSetMessageTest.php @@ -0,0 +1,37 @@ +drupalGet('system-test/drupal-set-message'); + $this->assertNoText('First message (removed).'); + $this->assertText('Second message (not removed).'); + } + +} diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index c5a10b8..52c0e55 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -25,6 +25,21 @@ public function mainContentFallback() { } /** + * Tests setting messages and removing one before it is displayed. + * @return string + * Empty string, we just test the setting of messages. + */ + public function drupalSetMessageTest() { + // Set two messages. + drupal_set_message('First message (removed).'); + drupal_set_message('Second message (not removed).'); + + // Remove the first. + unset($_SESSION['messages']['status'][0]); + return ''; + } + + /** * @todo Remove system_test_lock_acquire(). */ public function lockAcquire() { diff --git a/core/modules/system/tests/modules/system_test/system_test.routing.yml b/core/modules/system/tests/modules/system_test/system_test.routing.yml index 520ba37..32d235b 100644 --- a/core/modules/system/tests/modules/system_test/system_test.routing.yml +++ b/core/modules/system/tests/modules/system_test/system_test.routing.yml @@ -13,6 +13,14 @@ system_test.main_content_handling: requirements: _access: 'TRUE' +system_test.drupal_set_message: + path: '/system-test/drupal-set-message' + defaults: + _title: 'Set messages with drupal_set_message()' + _content: '\Drupal\system_test\Controller\SystemTestController::drupalSetMessageTest' + requirements: + _access: 'TRUE' + system_test.main_content_fallback: path: '/system-test/main-content-fallback' defaults: