function CommentNodeAccessTest::setUp

Same name 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. 10 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 29

Class

CommentNodeAccessTest
Tests comments with node access.

Namespace

Drupal\Tests\comment\Functional

Code

protected function setUp() {
    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.