CommentNodeAccessTest.php in Zircon Profile 8
File
core/modules/comment/src/Tests/CommentNodeAccessTest.php
View source
<?php
namespace Drupal\comment\Tests;
use Drupal\comment\CommentManagerInterface;
class CommentNodeAccessTest extends CommentTestBase {
public static $modules = array(
'node_access_test',
);
protected function setUp() {
parent::setUp();
node_access_rebuild();
$this->webUser = $this
->drupalCreateUser(array(
'access comments',
'post comments',
'create article content',
'edit own comments',
'node test view',
'skip comment approval',
));
$this->node
->setOwnerId($this->webUser
->id())
->save();
}
function testThreadedCommentView() {
$this
->drupalLogin($this->adminUser);
$this
->setCommentPreview(DRUPAL_DISABLED);
$this
->setCommentForm(TRUE);
$this
->setCommentSubject(TRUE);
$this
->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
$this
->drupalLogout();
$this
->drupalLogin($this->webUser);
$comment_text = $this
->randomMachineName();
$comment_subject = $this
->randomMachineName();
$comment = $this
->postComment($this->node, $comment_text, $comment_subject);
$this
->assertTrue($this
->commentExists($comment), 'Comment found.');
$this
->drupalGet('node/' . $this->node
->id());
$this
->assertText($comment_subject, 'Individual comment subject found.');
$this
->assertText($comment_text, 'Individual comment body found.');
$this
->drupalGet('comment/reply/node/' . $this->node
->id() . '/comment/' . $comment
->id());
$reply_text = $this
->randomMachineName();
$reply_subject = $this
->randomMachineName();
$reply = $this
->postComment(NULL, $reply_text, $reply_subject, TRUE);
$this
->assertTrue($this
->commentExists($reply, TRUE), 'Reply found.');
$this
->drupalGet('node/' . $this->node
->id());
$this
->assertText($comment_text);
$this
->assertText($comment_subject);
$this
->assertText($reply_text);
$this
->assertText($reply_subject);
}
}