function ForumTest::testForumWithNewPost

Tests a forum with a new post displays properly.

File

drupal/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php, line 466
Tests for forum.module.

Class

ForumTest
Provides automated tests for the Forum module.

Namespace

Drupal\forum\Tests

Code

function testForumWithNewPost() {

  // Login as the first user.
  $this
    ->drupalLogin($this->admin_user);

  // Create a forum container.
  $this->forumContainer = $this
    ->createForum('container');

  // Create a forum.
  $this->forum = $this
    ->createForum('forum');

  // Create a topic.
  $node = $this
    ->createForumTopic($this->forum, FALSE);

  // Login as a second user.
  $this
    ->drupalLogin($this->post_comment_user);

  // Post a reply to the topic.
  $edit = array();
  $edit['subject'] = $this
    ->randomName();
  $edit['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = $this
    ->randomName();
  $this
    ->drupalPost("node/{$node->nid}", $edit, t('Save'));
  $this
    ->assertResponse(200);

  // Login as the first user.
  $this
    ->drupalLogin($this->admin_user);

  // Check that forum renders properly.
  $this
    ->drupalGet("forum/{$this->forum['tid']}");
  $this
    ->assertResponse(200);
}