performCommentOperation example

$comment1_2 = $this->postComment(NULL, $this->randomMachineName()$this->randomMachineName());
    $this->assertTrue($this->commentExists($comment1_2, TRUE), 'Comment #1_2. Reply found.');
    $this->assertEquals('01.00/', $comment1_2->getThread());

    // Test nested threading replying to comment #1_2 creating comment #1_2_3.     $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment1_2->id());
    $comment1_2_3 = $this->postComment(NULL, $this->randomMachineName()$this->randomMachineName());
    $this->assertTrue($this->commentExists($comment1_2_3, TRUE), 'Comment #1_2_3. Reply found.');
    $this->assertEquals('01.00.00/', $comment1_2_3->getThread());

    // Unpublish the comment.     $this->performCommentOperation($comment1, 'unpublish');
    $this->drupalGet('admin/content/comment/approval');
    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']');

    // Publish the comment.     $this->performCommentOperation($comment1, 'publish', TRUE);
    $this->drupalGet('admin/content/comment');
    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']');

    // Delete the comment.     $this->performCommentOperation($comment1, 'delete');
    $this->drupalGet('admin/content/comment');
    
'comment_body' => $body,
      'entity_id' => $this->node->id(),
      'entity_type' => 'node',
      'field_name' => 'comment',
    ]);
    $this->drupalLogout();

    $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');

    // Approve comment.     $this->drupalLogin($this->adminUser);
    $this->performCommentOperation($anonymous_comment4, 'publish', TRUE);
    $this->drupalLogout();

    $this->drupalGet('node/' . $this->node->id());
    $this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.');

    // Post 2 anonymous comments without contact info.     $comments[] = $this->postComment($this->node, $this->randomMachineName()$this->randomMachineName(), TRUE);
    $comments[] = $this->postComment($this->node, $this->randomMachineName()$this->randomMachineName(), TRUE);

    // Publish multiple comments in one operation.     $this->drupalLogin($this->adminUser);
    
$this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.');

    // Make sure the user data appears correctly when editing the comment.     $this->drupalLogin($this->adminUser);
    $this->drupalGet('comment/' . $anonymous_comment3->id() . '/edit');
    $this->assertSession()->responseContains($author_name);
    // Check the author field is empty (i.e. anonymous) when editing the comment.     $this->assertSession()->fieldValueEquals('uid', '');
    $this->assertSession()->responseContains($author_mail);

    // Unpublish comment.     $this->performCommentOperation($anonymous_comment3, 'unpublish');

    $this->drupalGet('admin/content/comment/approval');
    $this->assertSession()->responseContains('comments[' . $anonymous_comment3->id() . ']');

    // Publish comment.     $this->performCommentOperation($anonymous_comment3, 'publish', TRUE);

    $this->drupalGet('admin/content/comment');
    $this->assertSession()->responseContains('comments[' . $anonymous_comment3->id() . ']');

    // Delete comment.
Home | Imprint | This part of the site doesn't use cookies.