function CommentTranslationUITest::createEntity

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

Overrides ContentTranslationTestBase::createEntity

1 call to CommentTranslationUITest::createEntity()
CommentTranslationUITest::testTranslateLinkCommentAdminPage in core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
Tests translate link on comment content admin page.

File

core/modules/comment/tests/src/Functional/CommentTranslationUITest.php, line 104

Class

CommentTranslationUITest
Tests the Comment Translation UI.

Namespace

Drupal\Tests\comment\Functional

Code

protected function createEntity($values, $langcode, $comment_type = 'comment_article') {
    if ($comment_type == 'comment_article') {
        // This is the article node type, with the 'comment_article' field.
        $node_type = 'article';
        $field_name = 'comment_article';
    }
    else {
        // This is the page node type with the non-translatable 'comment' field.
        $node_type = 'page';
        $field_name = 'comment';
    }
    $node = $this->drupalCreateNode([
        'type' => $node_type,
        $field_name => [
            [
                'status' => CommentItemInterface::OPEN,
            ],
        ],
    ]);
    $values['entity_id'] = $node->id();
    $values['entity_type'] = 'node';
    $values['field_name'] = $field_name;
    $values['uid'] = $node->getOwnerId();
    return parent::createEntity($values, $langcode, $comment_type);
}

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