Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\comment\Functional;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\comment\CommentManagerInterface;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Tests comments with node access.
|
Chris@0
|
9 *
|
Chris@0
|
10 * Verifies there is no PostgreSQL error when viewing a node with threaded
|
Chris@0
|
11 * comments (a comment and a reply), if a node access module is in use.
|
Chris@0
|
12 *
|
Chris@0
|
13 * @group comment
|
Chris@0
|
14 */
|
Chris@0
|
15 class CommentNodeAccessTest extends CommentTestBase {
|
Chris@0
|
16
|
Chris@0
|
17 /**
|
Chris@0
|
18 * Modules to install.
|
Chris@0
|
19 *
|
Chris@0
|
20 * @var array
|
Chris@0
|
21 */
|
Chris@0
|
22 public static $modules = ['node_access_test'];
|
Chris@0
|
23
|
Chris@0
|
24 protected function setUp() {
|
Chris@0
|
25 parent::setUp();
|
Chris@0
|
26
|
Chris@0
|
27 node_access_rebuild();
|
Chris@0
|
28
|
Chris@0
|
29 // Re-create user.
|
Chris@0
|
30 $this->webUser = $this->drupalCreateUser([
|
Chris@0
|
31 'access comments',
|
Chris@0
|
32 'post comments',
|
Chris@0
|
33 'create article content',
|
Chris@0
|
34 'edit own comments',
|
Chris@0
|
35 'node test view',
|
Chris@0
|
36 'skip comment approval',
|
Chris@0
|
37 ]);
|
Chris@0
|
38
|
Chris@0
|
39 // Set the author of the created node to the web_user uid.
|
Chris@0
|
40 $this->node->setOwnerId($this->webUser->id())->save();
|
Chris@0
|
41 }
|
Chris@0
|
42
|
Chris@0
|
43 /**
|
Chris@0
|
44 * Test that threaded comments can be viewed.
|
Chris@0
|
45 */
|
Chris@0
|
46 public function testThreadedCommentView() {
|
Chris@0
|
47 // Set comments to have subject required and preview disabled.
|
Chris@0
|
48 $this->drupalLogin($this->adminUser);
|
Chris@0
|
49 $this->setCommentPreview(DRUPAL_DISABLED);
|
Chris@0
|
50 $this->setCommentForm(TRUE);
|
Chris@0
|
51 $this->setCommentSubject(TRUE);
|
Chris@0
|
52 $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
|
Chris@0
|
53 $this->drupalLogout();
|
Chris@0
|
54
|
Chris@0
|
55 // Post comment.
|
Chris@0
|
56 $this->drupalLogin($this->webUser);
|
Chris@0
|
57 $comment_text = $this->randomMachineName();
|
Chris@0
|
58 $comment_subject = $this->randomMachineName();
|
Chris@0
|
59 $comment = $this->postComment($this->node, $comment_text, $comment_subject);
|
Chris@0
|
60 $this->assertTrue($this->commentExists($comment), 'Comment found.');
|
Chris@0
|
61
|
Chris@0
|
62 // Check comment display.
|
Chris@0
|
63 $this->drupalGet('node/' . $this->node->id());
|
Chris@0
|
64 $this->assertText($comment_subject, 'Individual comment subject found.');
|
Chris@0
|
65 $this->assertText($comment_text, 'Individual comment body found.');
|
Chris@0
|
66
|
Chris@0
|
67 // Reply to comment, creating second comment.
|
Chris@0
|
68 $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id());
|
Chris@0
|
69 $reply_text = $this->randomMachineName();
|
Chris@0
|
70 $reply_subject = $this->randomMachineName();
|
Chris@0
|
71 $reply = $this->postComment(NULL, $reply_text, $reply_subject, TRUE);
|
Chris@0
|
72 $this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.');
|
Chris@0
|
73
|
Chris@0
|
74 // Go to the node page and verify comment and reply are visible.
|
Chris@0
|
75 $this->drupalGet('node/' . $this->node->id());
|
Chris@0
|
76 $this->assertText($comment_text);
|
Chris@0
|
77 $this->assertText($comment_subject);
|
Chris@0
|
78 $this->assertText($reply_text);
|
Chris@0
|
79 $this->assertText($reply_subject);
|
Chris@0
|
80 }
|
Chris@0
|
81
|
Chris@0
|
82 }
|