public function ForumTest::testForumWithNewPost in Drupal 9
Same name and namespace in other branches
- 8 core/modules/forum/tests/src/Functional/ForumTest.php \Drupal\Tests\forum\Functional\ForumTest::testForumWithNewPost()
Tests a forum with a new post displays properly.
File
- core/
modules/ forum/ tests/ src/ Functional/ ForumTest.php, line 526
Class
- ForumTest
- Tests for forum.module.
Namespace
Drupal\Tests\forum\FunctionalCode
public function testForumWithNewPost() {
// Log in 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);
// Log in as a second user.
$this
->drupalLogin($this->postCommentUser);
// Post a reply to the topic.
$edit = [];
$edit['subject[0][value]'] = $this
->randomMachineName();
$edit['comment_body[0][value]'] = $this
->randomMachineName();
$this
->drupalGet('node/' . $node
->id());
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
// Test adding a new comment.
$this
->clickLink('Add new comment');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldExists('comment_body[0][value]');
// Log in as the first user.
$this
->drupalLogin($this->adminUser);
// Check that forum renders properly.
$this
->drupalGet("forum/{$this->forum['tid']}");
$this
->assertSession()
->statusCodeEquals(200);
// Verify there is no unintentional HTML tag escaping.
$this
->assertSession()
->assertNoEscaped('<');
}