function CommentTestBase::setUp

Same name in this branch
  1. 9 core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
Same name in other branches
  1. 8.9.x core/modules/comment/src/Tests/CommentTestBase.php \Drupal\comment\Tests\CommentTestBase::setUp()
  2. 8.9.x core/modules/comment/src/Tests/Views/CommentTestBase.php \Drupal\comment\Tests\Views\CommentTestBase::setUp()
  3. 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
  4. 8.9.x core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
  5. 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
  6. 10 core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
  7. 11.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
  8. 11.x core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()

Overrides BrowserTestBase::setUp

14 calls to CommentTestBase::setUp()
CommentAdminTest::setUp in core/modules/comment/tests/src/Functional/CommentAdminTest.php
CommentAdminTest::setUp in core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php
CommentAnonymousTest::setUp in core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
CommentAttributesTest::setUp in core/modules/rdf/tests/src/Functional/CommentAttributesTest.php
CommentBlockTest::setUp in core/modules/comment/tests/src/Functional/CommentBlockTest.php

... See full list

14 methods override CommentTestBase::setUp()
CommentAdminTest::setUp in core/modules/comment/tests/src/Functional/CommentAdminTest.php
CommentAdminTest::setUp in core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php
CommentAnonymousTest::setUp in core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
CommentAttributesTest::setUp in core/modules/rdf/tests/src/Functional/CommentAttributesTest.php
CommentBlockTest::setUp in core/modules/comment/tests/src/Functional/CommentBlockTest.php

... See full list

File

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

Class

CommentTestBase
Provides setup and helper methods for comment tests.

Namespace

Drupal\Tests\comment\Functional

Code

protected function setUp() {
    parent::setUp();
    // Create an article content type only if it does not yet exist, so that
    // child classes may specify the standard profile.
    $types = NodeType::loadMultiple();
    if (empty($types['article'])) {
        $this->drupalCreateContentType([
            'type' => 'article',
            'name' => t('Article'),
        ]);
    }
    // Create two test users.
    $this->adminUser = $this->drupalCreateUser([
        'administer content types',
        'administer comments',
        'administer comment types',
        'administer comment fields',
        'administer comment display',
        'skip comment approval',
        'post comments',
        'access comments',
        // Usernames aren't shown in comment edit form autocomplete unless this
        // permission is granted.
'access user profiles',
        'access content',
    ]);
    $this->webUser = $this->drupalCreateUser([
        'access comments',
        'post comments',
        'create article content',
        'edit own comments',
        'skip comment approval',
        'access content',
    ]);
    // Create comment field on article.
    $this->addDefaultCommentField('node', 'article');
    // Create a test node authored by the web user.
    $this->node = $this->drupalCreateNode([
        'type' => 'article',
        'promote' => 1,
        'uid' => $this->webUser
            ->id(),
    ]);
    $this->drupalPlaceBlock('local_tasks_block');
}

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