You are here

function ForumTest::testForumWithNewPost in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/forum/src/Tests/ForumTest.php \Drupal\forum\Tests\ForumTest::testForumWithNewPost()

Tests a forum with a new post displays properly.

File

core/modules/forum/src/Tests/ForumTest.php, line 488
Contains \Drupal\forum\Tests\ForumTest.

Class

ForumTest
Create, view, edit, delete, and change forum entries and verify its consistency in the database.

Namespace

Drupal\forum\Tests

Code

function testForumWithNewPost() {

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

  // 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->postCommentUser);

  // Post a reply to the topic.
  $edit = array();
  $edit['subject[0][value]'] = $this
    ->randomMachineName();
  $edit['comment_body[0][value]'] = $this
    ->randomMachineName();
  $this
    ->drupalPostForm('node/' . $node
    ->id(), $edit, t('Save'));
  $this
    ->assertResponse(200);

  // Test replying to a comment.
  $this
    ->clickLink('Reply');
  $this
    ->assertResponse(200);
  $this
    ->assertFieldByName('comment_body[0][value]');

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

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