function CommentNodeAccessTest::setUp

Same name and namespace in other branches
  1. 7.x modules/comment/comment.test \CommentNodeAccessTest::setUp()
  2. 9 core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::setUp()
  3. 8.9.x core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::setUp()
  4. 11.x core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php \Drupal\Tests\comment\Functional\CommentNodeAccessTest::setUp()

Overrides CommentTestBase::setUp

File

core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php, line 32

Class

CommentNodeAccessTest
Tests comments with node access.

Namespace

Drupal\Tests\comment\Functional

Code

protected function setUp() : void {
  parent::setUp();
  node_access_rebuild();
  // Re-create user.
  $this->webUser = $this->drupalCreateUser([
    'access comments',
    'post comments',
    'create article content',
    'edit own comments',
    'node test view',
    'skip comment approval',
  ]);
  // Set the author of the created node to the web_user uid.
  $this->node
    ->setOwnerId($this->webUser
    ->id())
    ->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.