function setUp() { parent::setUp(); $this->languageManager = $this->container->get('language_manager'); $this->installEntitySchema('entity_test_rev'); $this->installEntitySchema('entity_test_mul'); $this->installEntitySchema('entity_test_mulrev'); $this->installConfig(array('language')); // Create the test field. entity_test_install(); // Enable translations for the test entity type. $this->state->set('entity_test.translation', TRUE); // Create a translatable test field. $this->field_name = drupal_strtolower($this->randomMachineName() . '_field_name'); // Create an untranslatable test field. $this->untranslatable_field_name = drupal_strtolower($this->randomMachineName() . '_field_name'); // Create field instances in all entity variations. foreach (entity_test_entity_types() as $entity_type) { entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save(); entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save(); $this->instance[$entity_type] = entity_load('field_instance_config', $entity_type . '.' . $entity_type . '.' . $this->field_name); entity_create('field_storage_config', array('name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save(); entity_create('field_instance_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save(); } // Create the default languages. $default_language = language_save($this->languageManager->getDefaultLanguage()); $languages = $this->languageManager->getDefaultLockedLanguages($default_language->weight); foreach ($languages as $language) { language_save($language); } // Create test languages. $this->langcodes = array(); for ($i = 0; $i < 3; ++$i) { $language = new Language(array('id' => 'l' . $i, 'name' => $this->randomString(), 'weight' => $i)); $this->langcodes[$i] = $language->id; language_save($language); } }