Skip to content
Snippets Groups Projects
Unverified Commit dd103d84 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2886615 by scott_euser, clemens.tolboom, quietone, joachim, alexpott,...

Issue #2886615 by scott_euser, clemens.tolboom, quietone, joachim, alexpott, Lendude: comment_empty_title_test has invalid hook

(cherry picked from commit d7082acf)
parent f5a452bd
No related branches found
No related tags found
No related merge requests found
......@@ -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'] = '';
}
......@@ -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.
......@@ -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);
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment