diff --git a/core/modules/comment/src/Tests/CommentTitleTest.php b/core/modules/comment/src/Tests/CommentTitleTest.php index a2e939f..598c410 100644 --- a/core/modules/comment/src/Tests/CommentTitleTest.php +++ b/core/modules/comment/src/Tests/CommentTitleTest.php @@ -2,21 +2,19 @@ /** * @file - * Definition of Drupal\comment\Tests\CommentTitleTest. + * Contains \Drupal\comment\Tests\CommentTitleTest. */ namespace Drupal\comment\Tests; -use Drupal\Core\Language\Language; - /** - * Tests comment with empty titles. + * Tests comment titles. */ class CommentTitleTest extends CommentTestBase { public static function getInfo() { return array( 'name' => 'Comment titles', - 'description' => 'Test to ensure that appropriate and accessible markup is created to titles.', + 'description' => 'Test to ensure that appropriate and accessible markup is created for comment titles.', 'group' => 'Comment', ); } @@ -25,8 +23,8 @@ public static function getInfo() { * Tests markup for comments with empty titles. */ public function testCommentEmptyTitles() { - // Enables module that sets comments to = ''. - \Drupal::moduleHandler()->install(array('comment_test_empty_titles')); + // Enables module that sets comments to an empty string. + \Drupal::moduleHandler()->install(array('comment_empty_titles_test')); // Set comments to have a subject with preview disabled. $this->drupalLogin($this->admin_user); @@ -39,8 +37,7 @@ public function testCommentEmptyTitles() { $this->drupalLogin($this->web_user); $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->id())); - // Post comment #1 and verify that title is rendered in h3. - $this->drupalLogin($this->web_user); + // Post comment #1 and verify that h3's are not rendered. $subject_text = $this->randomName(); $comment_text = $this->randomName(); $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); @@ -50,11 +47,11 @@ public function testCommentEmptyTitles() { $regex .= '/s'; $this->assertPattern($regex, 'Comment is created succesfully'); // Tests that markup is not generated for the comment without header. - $this->assertNoPattern('|]*>|', 'H3 for comment title element found when no title present.'); + $this->assertNoPattern('|]*>|', 'Comment title H3 element not found when title is an empty string.'); } /** - * Tests markup for comments with empty titles. + * Tests markup for comments with populated titles. */ public function testCommentPopulatedTitles() { // Set comments to have a subject with preview disabled. @@ -69,13 +66,12 @@ public function testCommentPopulatedTitles() { $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->id())); // Post comment #1 and verify that title is rendered in h3. - $this->drupalLogin($this->web_user); $subject_text = $this->randomName(); $comment_text = $this->randomName(); $comment1 = $this->postComment($this->node, $comment_text, $subject_text, TRUE); // Confirm that the comment was created. $this->assertTrue($this->commentExists($comment1), 'Comment #1. Comment found.'); // Tests that markup is created for comment with heading. - $this->assertPattern('|]*>]*>' . $subject_text . '|', 'H3 element not found when title present.'); + $this->assertPattern('|]*>]*>' . $subject_text . '|', 'Comment title is rendered in h3 when title populated.'); } } diff --git a/core/modules/comment/tests/modules/comment_empty_titles_test/comment_empty_titles_test.info.yml b/core/modules/comment/tests/modules/comment_empty_titles_test/comment_empty_titles_test.info.yml new file mode 100644 index 0000000..4ff7f61 --- /dev/null +++ b/core/modules/comment/tests/modules/comment_empty_titles_test/comment_empty_titles_test.info.yml @@ -0,0 +1,8 @@ +name: 'Comment empty titles test' +type: module +description: 'Support module for testing empty title accessibility with Comment module.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - comment diff --git a/core/modules/comment/tests/modules/comment_empty_titles_test/comment_empty_titles_test.module b/core/modules/comment/tests/modules/comment_empty_titles_test/comment_empty_titles_test.module new file mode 100644 index 0000000..629d8b9 --- /dev/null +++ b/core/modules/comment/tests/modules/comment_empty_titles_test/comment_empty_titles_test.module @@ -0,0 +1,16 @@ +