function CommentTestBase::setUp
Same name in this branch
- 8.9.x core/modules/comment/src/Tests/CommentTestBase.php \Drupal\comment\Tests\CommentTestBase::setUp()
- 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
- 8.9.x core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
- 9 core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
- 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
- 10 core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
- 11.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setUp()
- 11.x core/modules/comment/tests/src/Functional/Views/CommentTestBase.php \Drupal\Tests\comment\Functional\Views\CommentTestBase::setUp()
Overrides ViewTestBase::setUp
File
-
core/
modules/ comment/ src/ Tests/ Views/ CommentTestBase.php, line 66
Class
- CommentTestBase
- Provides setup and helper methods for comment views tests.
Namespace
Drupal\comment\Tests\ViewsCode
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), [
'comment_test_views',
]);
// 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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.