You are here

public function EckEntityTranslationTest::setUp in Entity Construction Kit (ECK) 8

Overrides FunctionalTestBase::setUp

File

tests/src/Functional/EckEntityTranslationTest.php, line 50

Class

EckEntityTranslationTest
Tests translating ECK entities.

Namespace

Drupal\Tests\eck\Functional

Code

public function setUp() {
  parent::setUp();

  // Create new entity type.
  $this->entityType = $this
    ->createEntityType([], 'translatable');
  $this->bundle = $this
    ->createEntityBundle($this->entityType['id'], 'translatable');

  // Add one more language.
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->submitForm([
    'predefined_langcode' => 'uk',
  ], t('Add language'));

  // Enable content translation on newly created entity type.
  $this
    ->drupalGet('admin/config/regional/content-language');
  $edit = [
    "entity_types[{$this->entityType['id']}]" => TRUE,
    "settings[{$this->entityType['id']}][{$this->bundle['type']}][translatable]" => TRUE,
  ];
  $this
    ->submitForm($edit, 'Save configuration');

  // Adding languages requires a container rebuild in the test running
  // environment so that multilingual services are used.
  $this
    ->resetAll();
}