diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index e9ccb3e..2d0152a 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -506,7 +506,7 @@ function template_preprocess_forums(&$variables) { } $row[] = array( - 'data' => $topic->comment_count . $new_replies, + 'data' => array('#markup' => $topic->comment_count . $new_replies), 'class' => array('forum__replies'), ); $row[] = array( diff --git a/core/modules/forum/src/Tests/ForumIndexTest.php b/core/modules/forum/src/Tests/ForumIndexTest.php index b9ee537..8b98e32 100644 --- a/core/modules/forum/src/Tests/ForumIndexTest.php +++ b/core/modules/forum/src/Tests/ForumIndexTest.php @@ -17,6 +17,20 @@ class ForumIndexTest extends WebTestBase { /** + * User account with limited access to forum pages + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $webUser; + + /** + * User account with limited access to forum pages + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $forumUser; + + /** * Modules to enable. * * @var array @@ -27,14 +41,15 @@ protected function setUp() { parent::setUp(); // Create a test user. - $web_user = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes')); - $this->drupalLogin($web_user); + $this->webUser = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes')); + $this->forumUser = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes', 'administer comments', 'post comments', 'skip comment approval')); } /** * Tests the forum index for published and unpublished nodes. */ - function testForumIndexStatus() { + public function testForumIndexStatus() { + $this->drupalLogin($this->webUser); // The forum ID to use. $tid = 1; @@ -68,4 +83,40 @@ function testForumIndexStatus() { $this->drupalGet('forum/' . $tid); $this->assertNoText($title, 'Unpublished forum topic no longer appears on index.'); } + + public function testHistory() { + $this->drupalLogin($this->webUser); + // The forum ID to use. + $tid = 1; + + // Create a test node. + $title = $this->randomMachineName(20); + $edit = array( + 'title[0][value]' => $title, + 'body[0][value]' => $this->randomMachineName(200), + ); + + // Create the forum topic, preselecting the forum ID via a URL parameter. + $this->drupalGet("forum/$tid"); + $this->clickLink(t('Add new @node_type', array('@node_type' => 'Forum topic'))); + $this->drupalPostForm(NULL, $edit, t('Save and publish')); + + // Login as the forum user to create a reply + $this->drupalLogin($this->forumUser); + + // Mockup a comment + $edit = array(); + $edit['comment_body[0][value]'] = $this->randomMachineName(); + + // Create comment + $this->drupalGet("forum/$tid"); + $this->clickLink(t($title)); + $this->drupalPostForm(NULL, $edit, t('Save')); + + // Verify the new post link is not raw + $this->drupalLogin($this->webUser); + $this->drupalGet("forum/$tid"); + $this->assertRaw('1
1 new post in topic ' . $title . ''); + } } +