Loading core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module +1 −1 Original line number Diff line number Diff line Loading @@ -9,6 +9,6 @@ /** * Implements hook_preprocess_comment(). */ function comment_empty_titles_test_preprocess_comment(&$variables) { function comment_empty_title_test_preprocess_comment(&$variables) { $variables['title'] = ''; } core/modules/comment/tests/src/Functional/CommentTitleTest.php +18 −6 Original line number Diff line number Diff line Loading @@ -19,7 +19,19 @@ class CommentTitleTest extends CommentTestBase { * Tests markup for comments with empty titles. */ public function testCommentEmptyTitles() { // Installs module that sets comments to an empty string. // Create a node. $this->drupalLogin($this->webUser); $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1 and verify that h3 is rendered. $subject_text = "Test subject"; $comment_text = "Test comment"; $this->postComment($this->node, $comment_text, $subject_text, TRUE); // Tests that markup is generated for the comment title. $regex_h3 = '|<h3[^>]*>.*?</h3>|'; $this->assertSession()->responseMatches($regex_h3); // Installs module that sets comment title to an empty string. \Drupal::service('module_installer')->install(['comment_empty_title_test']); // Set comments to have a subject with preview disabled. Loading @@ -27,11 +39,10 @@ public function testCommentEmptyTitles() { $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); // Create a node. $this->drupalLogin($this->webUser); // Create a new node. $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1 and verify that h3's are not rendered. // Post another comment and verify that h3 is not rendered. $subject_text = $this->randomMachineName(); $comment_text = $this->randomMachineName(); $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); Loading @@ -47,8 +58,9 @@ public function testCommentEmptyTitles() { $regex .= '/s'; // Verify that the comment is created successfully. $this->assertSession()->responseMatches($regex); // Tests that markup is not generated for the comment without header. $this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|'); // Tests that markup is not generated for the comment title. $this->assertSession()->responseNotMatches($regex_h3); $this->assertSession()->pageTextNotContains($subject_text); } /** Loading Loading
core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module +1 −1 Original line number Diff line number Diff line Loading @@ -9,6 +9,6 @@ /** * Implements hook_preprocess_comment(). */ function comment_empty_titles_test_preprocess_comment(&$variables) { function comment_empty_title_test_preprocess_comment(&$variables) { $variables['title'] = ''; }
core/modules/comment/tests/src/Functional/CommentTitleTest.php +18 −6 Original line number Diff line number Diff line Loading @@ -19,7 +19,19 @@ class CommentTitleTest extends CommentTestBase { * Tests markup for comments with empty titles. */ public function testCommentEmptyTitles() { // Installs module that sets comments to an empty string. // Create a node. $this->drupalLogin($this->webUser); $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1 and verify that h3 is rendered. $subject_text = "Test subject"; $comment_text = "Test comment"; $this->postComment($this->node, $comment_text, $subject_text, TRUE); // Tests that markup is generated for the comment title. $regex_h3 = '|<h3[^>]*>.*?</h3>|'; $this->assertSession()->responseMatches($regex_h3); // Installs module that sets comment title to an empty string. \Drupal::service('module_installer')->install(['comment_empty_title_test']); // Set comments to have a subject with preview disabled. Loading @@ -27,11 +39,10 @@ public function testCommentEmptyTitles() { $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); // Create a node. $this->drupalLogin($this->webUser); // Create a new node. $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1 and verify that h3's are not rendered. // Post another comment and verify that h3 is not rendered. $subject_text = $this->randomMachineName(); $comment_text = $this->randomMachineName(); $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); Loading @@ -47,8 +58,9 @@ public function testCommentEmptyTitles() { $regex .= '/s'; // Verify that the comment is created successfully. $this->assertSession()->responseMatches($regex); // Tests that markup is not generated for the comment without header. $this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|'); // Tests that markup is not generated for the comment title. $this->assertSession()->responseNotMatches($regex_h3); $this->assertSession()->pageTextNotContains($subject_text); } /** Loading