protected function EntityTranslationWorkflowsTest::setupEntity

Creates a test entity and translate it.

1 call to EntityTranslationWorkflowsTest::setupEntity()
EntityTranslationWorkflowsTest::setUp in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php
Sets up a Drupal site for running functional and integration tests.

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php, line 55
Contains \Drupal\entity\Tests\EntityTranslationWorkflowsTest.

Class

EntityTranslationWorkflowsTest
Tests entity translation workflows.

Namespace

Drupal\translation_entity\Tests

Code

protected function setupEntity() {
  $default_langcode = $this->langcodes[0];

  // Create a test entity.
  $values = array(
    'name' => $this
      ->randomName(),
    'user_id' => mt_rand(1, 128),
    $this->fieldName => array(
      array(
        'value' => $this
          ->randomName(16),
      ),
    ),
  );
  $id = $this
    ->createEntity($values, $default_langcode);
  $this->entity = entity_load($this->entityType, $id, TRUE);

  // Create a translation.
  $this
    ->drupalLogin($this->translator);
  $add_translation_path = $this->controller
    ->getBasePath($this->entity) . "/translations/add/{$default_langcode}/{$this->langcodes[2]}";
  $this
    ->drupalPost($add_translation_path, array(), t('Save'));
  $this
    ->rebuildContainer();
}