Loading core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +2 −1 Original line number Diff line number Diff line Loading @@ -118,8 +118,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#title' => $this->t('Comments per page'), '#default_value' => $settings['per_page'], '#required' => TRUE, '#min' => 1, '#min' => 0, '#max' => 1000, '#description' => $this->t('Enter 0 to show all comments.'), ]; $element['anonymous'] = [ '#type' => 'select', Loading core/modules/comment/tests/src/Functional/CommentFieldsTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,15 @@ public function testCommentFieldCreate() { $this->submitForm($edit, 'Save field settings'); // We shouldn't get an error message. $this->assertSession()->pageTextNotContains('The submitted value in the Comment type element is not allowed.'); // Try to save the comment field with "Comments per page" // setting value as zero. $edit = [ 'settings[per_page]' => 0, ]; $this->drupalGet('admin/config/people/accounts/fields/user.user.field_user_comment'); $this->submitForm($edit, 'Save settings'); $this->assertSession()->statusMessageContains('Saved User comment configuration.', 'status'); } /** Loading core/modules/comment/tests/src/Functional/CommentPagerTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,14 @@ public function testCommentPaging() { $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.'); // Set "Comments per page" as zero and verify that all comments are appearing // on the page. $this->setCommentsPerPage(0); $this->drupalGet('node/' . $node->id()); $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page.'); $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page.'); $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page.'); // Set comments to one per page so that we are able to test paging without // needing to insert large numbers of comments. $this->setCommentsPerPage(1); Loading Loading @@ -92,6 +100,10 @@ public function testCommentPaging() { $this->setCommentsPerPage(0); $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertFalse($this->commentExists($reply2, TRUE), 'Threaded mode works correctly when comments per page is 0.'); // Test that all main comments are appearing in the threaded mode. $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page.'); $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page.'); $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page.'); $this->drupalLogout(); } Loading Loading
core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +2 −1 Original line number Diff line number Diff line Loading @@ -118,8 +118,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#title' => $this->t('Comments per page'), '#default_value' => $settings['per_page'], '#required' => TRUE, '#min' => 1, '#min' => 0, '#max' => 1000, '#description' => $this->t('Enter 0 to show all comments.'), ]; $element['anonymous'] = [ '#type' => 'select', Loading
core/modules/comment/tests/src/Functional/CommentFieldsTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,15 @@ public function testCommentFieldCreate() { $this->submitForm($edit, 'Save field settings'); // We shouldn't get an error message. $this->assertSession()->pageTextNotContains('The submitted value in the Comment type element is not allowed.'); // Try to save the comment field with "Comments per page" // setting value as zero. $edit = [ 'settings[per_page]' => 0, ]; $this->drupalGet('admin/config/people/accounts/fields/user.user.field_user_comment'); $this->submitForm($edit, 'Save settings'); $this->assertSession()->statusMessageContains('Saved User comment configuration.', 'status'); } /** Loading
core/modules/comment/tests/src/Functional/CommentPagerTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,14 @@ public function testCommentPaging() { $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.'); // Set "Comments per page" as zero and verify that all comments are appearing // on the page. $this->setCommentsPerPage(0); $this->drupalGet('node/' . $node->id()); $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page.'); $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page.'); $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page.'); // Set comments to one per page so that we are able to test paging without // needing to insert large numbers of comments. $this->setCommentsPerPage(1); Loading Loading @@ -92,6 +100,10 @@ public function testCommentPaging() { $this->setCommentsPerPage(0); $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertFalse($this->commentExists($reply2, TRUE), 'Threaded mode works correctly when comments per page is 0.'); // Test that all main comments are appearing in the threaded mode. $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page.'); $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page.'); $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page.'); $this->drupalLogout(); } Loading