3 namespace Drupal\comment\Tests\Views;
5 use Drupal\comment\Tests\CommentTestTrait;
6 use Drupal\views\Tests\ViewTestBase;
7 use Drupal\views\Tests\ViewTestData;
8 use Drupal\comment\Entity\Comment;
11 * Tests the argument_comment_user_uid handler.
13 abstract class CommentTestBase extends ViewTestBase {
22 public static $modules = ['node', 'comment', 'comment_test_views'];
25 * A normal user with permission to post comments (without approval).
27 * @var \Drupal\user\UserInterface
32 * A second normal user that will author a node for $account to comment on.
34 * @var \Drupal\user\UserInterface
39 * Stores a node posted by the user created as $account.
41 * @var \Drupal\node\NodeInterface
43 protected $nodeUserPosted;
46 * Stores a node posted by the user created as $account2.
48 * @var \Drupal\node\NodeInterface
50 protected $nodeUserCommented;
53 * Stores a comment used by the tests.
55 * @var \Drupal\comment\Entity\Comment
59 protected function setUp() {
62 ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
64 // Add two users, create a node with the user1 as author and another node
65 // with user2 as author. For the second node add a comment from user1.
66 $this->account = $this->drupalCreateUser(['skip comment approval']);
67 $this->account2 = $this->drupalCreateUser();
68 $this->drupalLogin($this->account);
70 $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
71 $this->addDefaultCommentField('node', 'page');
73 $this->nodeUserPosted = $this->drupalCreateNode();
74 $this->nodeUserCommented = $this->drupalCreateNode(['uid' => $this->account2->id()]);
77 'uid' => $this->loggedInUser->id(),
78 'entity_id' => $this->nodeUserCommented->id(),
79 'entity_type' => 'node',
80 'field_name' => 'comment',
81 'subject' => 'How much wood would a woodchuck chuck',
84 'mail' => 'someone@example.com',
86 $this->comment = Comment::create($comment);
87 $this->comment->save();