You are here

protected function CommentTranslationUITest::createEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/comment/tests/src/Functional/CommentTranslationUITest.php \Drupal\Tests\comment\Functional\CommentTranslationUITest::createEntity()

Creates the entity to be translated.

Parameters

array $values: An array of initial values for the entity.

string $langcode: The initial language code of the entity.

string $bundle_name: (optional) The entity bundle, if the entity uses bundles. Defaults to NULL. If left NULL, $this->bundle will be used.

Return value

string The entity id.

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 101

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);
}