Same name in this branch
  1. 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
  2. 10 core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
Same name and namespace in other branches
  1. 8.9.x core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
  2. 9 core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()

Sets up the test.

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

array $modules: The module directories to look in for test views.

Overrides ViewTestBase::setUp

2 calls to CommentTestBase::setUp()
CommentApproveLinkTest::setUp in core/modules/comment/tests/src/Functional/Views/CommentApproveLinkTest.php
Sets up the test.
CommentFieldFilterTest::setUp in core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
Sets up the test.
2 methods override CommentTestBase::setUp()
CommentApproveLinkTest::setUp in core/modules/comment/tests/src/Functional/Views/CommentApproveLinkTest.php
Sets up the test.
CommentFieldFilterTest::setUp in core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
Sets up the test.

File

core/modules/comment/tests/src/Functional/Views/CommentTestBase.php, line 63

Class

CommentTestBase
Provides setup and helper methods for comment views tests.

Namespace

Drupal\Tests\comment\Functional\Views

Code

protected function setUp($import_test_views = TRUE, $modules = [
  'comment_test_views',
]) : void {
  parent::setUp($import_test_views, $modules);

  // Add two users, create a node with the user1 as author and another node
  // with user2 as author. For the second node add a comment from user1.
  $this->account = $this
    ->drupalCreateUser([
    'skip comment approval',
  ]);
  $this->account2 = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($this->account);
  $this
    ->drupalCreateContentType([
    'type' => 'page',
    'name' => t('Basic page'),
  ]);
  $this
    ->addDefaultCommentField('node', 'page');
  $this->nodeUserPosted = $this
    ->drupalCreateNode();
  $this->nodeUserCommented = $this
    ->drupalCreateNode([
    'uid' => $this->account2
      ->id(),
  ]);
  $comment = [
    'uid' => $this->loggedInUser
      ->id(),
    'entity_id' => $this->nodeUserCommented
      ->id(),
    'entity_type' => 'node',
    'field_name' => 'comment',
    'subject' => 'How much wood would a woodchuck chuck',
    'cid' => '',
    'pid' => '',
    'mail' => 'someone@example.com',
  ];
  $this->comment = Comment::create($comment);
  $this->comment
    ->save();
}