3 namespace Drupal\comment\Tests\Views;
5 @trigger_error(__NAMESPACE__ . '\CommentTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\Tests\comment\Functional\Views\CommentTestBase instead. See http://www.drupal.org/node/2908490', E_USER_DEPRECATED);
7 use Drupal\comment\Tests\CommentTestTrait;
8 use Drupal\views\Tests\ViewTestBase;
9 use Drupal\views\Tests\ViewTestData;
10 use Drupal\comment\Entity\Comment;
13 * Provides setup and helper methods for comment views tests.
15 * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
16 * Use \Drupal\Tests\comment\Functional\Views\CommentTestBase instead.
18 * @see https://www.drupal.org/node/2908490
20 abstract class CommentTestBase extends ViewTestBase {
29 public static $modules = ['node', 'comment', 'comment_test_views'];
32 * A normal user with permission to post comments (without approval).
34 * @var \Drupal\user\UserInterface
39 * A second normal user that will author a node for $account to comment on.
41 * @var \Drupal\user\UserInterface
46 * Stores a node posted by the user created as $account.
48 * @var \Drupal\node\NodeInterface
50 protected $nodeUserPosted;
53 * Stores a node posted by the user created as $account2.
55 * @var \Drupal\node\NodeInterface
57 protected $nodeUserCommented;
60 * Stores a comment used by the tests.
62 * @var \Drupal\comment\Entity\Comment
66 protected function setUp($import_test_views = TRUE) {
67 parent::setUp($import_test_views);
69 ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
71 // Add two users, create a node with the user1 as author and another node
72 // with user2 as author. For the second node add a comment from user1.
73 $this->account = $this->drupalCreateUser(['skip comment approval']);
74 $this->account2 = $this->drupalCreateUser();
75 $this->drupalLogin($this->account);
77 $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
78 $this->addDefaultCommentField('node', 'page');
80 $this->nodeUserPosted = $this->drupalCreateNode();
81 $this->nodeUserCommented = $this->drupalCreateNode(['uid' => $this->account2->id()]);
84 'uid' => $this->loggedInUser->id(),
85 'entity_id' => $this->nodeUserCommented->id(),
86 'entity_type' => 'node',
87 'field_name' => 'comment',
88 'subject' => 'How much wood would a woodchuck chuck',
91 'mail' => 'someone@example.com',
93 $this->comment = Comment::create($comment);
94 $this->comment->save();