function CommentAccessTest::setUp

Same name in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::setUp()
  2. 10 core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::setUp()
  3. 11.x core/modules/comment/tests/src/Functional/CommentAccessTest.php \Drupal\Tests\comment\Functional\CommentAccessTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/comment/tests/src/Functional/CommentAccessTest.php, line 42

Class

CommentAccessTest
Tests comment administration and preview access.

Namespace

Drupal\Tests\comment\Functional

Code

protected function setUp() {
    parent::setUp();
    $node_type = NodeType::create([
        'type' => 'article',
        'name' => 'Article',
    ]);
    $node_type->save();
    $node_author = $this->drupalCreateUser([
        'create article content',
        'access comments',
    ]);
    $this->drupalLogin($this->drupalCreateUser([
        'edit own comments',
        'skip comment approval',
        'post comments',
        'access comments',
        'access content',
    ]));
    $this->addDefaultCommentField('node', 'article');
    $this->unpublishedNode = $this->createNode([
        'title' => 'This is unpublished',
        'uid' => $node_author->id(),
        'status' => 0,
        'type' => 'article',
    ]);
    $this->unpublishedNode
        ->save();
}

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