3 namespace Drupal\Tests\tracker\Functional\Views;
5 use Drupal\comment\Tests\CommentTestTrait;
6 use Drupal\Core\Language\LanguageInterface;
7 use Drupal\Tests\views\Functional\ViewTestBase;
8 use Drupal\views\Tests\ViewTestData;
9 use Drupal\comment\Entity\Comment;
12 * Base class for all tracker tests.
14 abstract class TrackerTestBase extends ViewTestBase {
23 public static $modules = ['comment', 'tracker', 'tracker_test_views'];
26 * The node used for testing.
28 * @var \Drupal\node\NodeInterface
33 * The comment used for testing.
35 * @var \Drupal\comment\CommentInterface
39 protected function setUp($import_test_views = TRUE) {
40 parent::setUp($import_test_views);
42 ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
44 $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
45 // Add a comment field.
46 $this->addDefaultCommentField('node', 'page');
48 $permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
49 $account = $this->drupalCreateUser($permissions);
51 $this->drupalLogin($account);
53 $this->node = $this->drupalCreateNode([
54 'title' => $this->randomMachineName(8),
55 'uid' => $account->id(),
59 $this->comment = Comment::create([
60 'entity_id' => $this->node->id(),
61 'entity_type' => 'node',
62 'field_name' => 'comment',
63 'subject' => $this->randomMachineName(),
64 'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20),