Commit 98217b5b authored by catch's avatar catch
Browse files

Issue #2986372 by ranjith_kumar_k_u, robertom, _utsavsharma, smustgrave,...

Issue #2986372 by ranjith_kumar_k_u, robertom, _utsavsharma, smustgrave, penyaskito, catch, larowlan: "Comments per page" setting cannot be configured to "all comments"
parent 8149f97c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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',
+9 −0
Original line number Diff line number Diff line
@@ -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');
  }

  /**
+12 −0
Original line number Diff line number Diff line
@@ -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);
@@ -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();
  }