Commit 1d707401 authored by alexpott's avatar alexpott

Issue #1946240 by eiriksm, David_Rothstein, Yaron Tal, madhusudanmca, rszrama:...

Issue #1946240 by eiriksm, David_Rothstein, Yaron Tal, madhusudanmca, rszrama: Remove the hardcoded 0 index in status-messages.html.twig.
parent c033857b
<?php
/**
* @file
* Contains \Drupal\system\Tests\Bootstrap\DrupalSetMessageTest.
*/
namespace Drupal\system\Tests\Bootstrap;
use Drupal\simpletest\WebTestBase;
/**
* Tests drupal_set_message() and related functions.
*
* @group Bootstrap
*/
class DrupalSetMessageTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system_test');
/**
* Tests setting messages and removing one before it is displayed.
*/
function testSetRemoveMessages() {
// The page at system-test/drupal-set-message sets two messages and then
// removes the first before it is displayed.
$this->drupalGet('system-test/drupal-set-message');
$this->assertNoText('First message (removed).');
$this->assertText('Second message (not removed).');
}
}
......@@ -44,7 +44,7 @@
{% endfor %}
</ul>
{% else %}
{{ messages.0 }}
{{ messages|first }}
{% endif %}
{% if type == 'error' %}
</div>
......
......@@ -24,6 +24,22 @@ public function mainContentFallback() {
return $this->t('Content to test main content fallback');
}
/**
* 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().
*/
......
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment