protected function EntityTranslationUITest::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

The entity id.

5 calls to EntityTranslationUITest::createEntity()
CommentTranslationUITest::createEntity in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::createEntity().
ConfigTestTranslationUITest::testTranslationUI in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/ConfigTestTranslationUITest.php
Overrides EntityTranslationTest::testTranslationUI().
EntityTranslationUITest::testTranslationUI in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
Tests the basic translation UI.
TermTranslationUITest::createEntity in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::createEntity().
UserTranslationUITest::testTranslateLinkUserAdminPage in drupal/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php
Tests translate link on user admin list.
2 methods override EntityTranslationUITest::createEntity()

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php, line 241
Definition of Drupal\entity\Tests\EntityTranslationUITest.

Class

EntityTranslationUITest
Tests the Entity Translation UI.

Namespace

Drupal\translation_entity\Tests

Code

protected function createEntity($values, $langcode, $bundle_name = NULL) {
  $entity_values = $values;
  $entity_values['langcode'] = $langcode;
  $info = entity_get_info($this->entityType);
  if (!empty($info['entity_keys']['bundle'])) {
    $entity_values[$info['entity_keys']['bundle']] = $bundle_name ?: $this->bundle;
  }
  $controller = entity_get_controller($this->entityType);
  if (!$controller instanceof DatabaseStorageControllerNG) {
    foreach ($values as $property => $value) {
      if (is_array($value)) {
        $entity_values[$property] = array(
          $langcode => $value,
        );
      }
    }
  }
  $entity = entity_create($this->entityType, $entity_values);
  $entity
    ->save();
  return $entity
    ->id();
}