protected 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 fields in all entity variations. foreach (entity_test_entity_types() as $entity_type) { entity_create('field_storage_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save(); entity_create('field_config', array('field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE))->save(); $this->field[$entity_type] = entity_load('field_config', $entity_type . '.' . $entity_type . '.' . $this->field_name); entity_create('field_storage_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save(); entity_create('field_config', array('field_name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE))->save(); } // Create the default languages. $this->installConfig(array('language')); // Create test languages. $this->langcodes = array(); for ($i = 0; $i < 3; ++$i) { $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i)); $this->langcodes[$i] = $language->getId(); $language->save(); } }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create the test field. entity_test_install(); // Install required default configuration for filter module. $this->installConfig(array('system', 'filter')); }
protected function setUp() { parent::setUp(); // Install field configuration. $this->installConfig(array('field')); // The users table is needed for creating dummy user accounts. $this->installEntitySchema('user'); // Register entity_test text field. module_load_install('entity_test'); entity_test_install(); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_rev'); $this->installEntitySchema('entity_test_mul'); $this->installEntitySchema('entity_test_mulrev'); // Create the test field. entity_test_install(); // Install required default configuration for filter module. $this->installConfig(array('system', 'filter')); }
protected function setUp() { parent::setUp(); foreach (entity_test_entity_types() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); } } // Create the test field. entity_test_install(); // Install required default configuration for filter module. $this->installConfig(array('system', 'filter')); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); // Add the languages. $this->installConfig(['language']); ConfigurableLanguage::createFromLangcode('de')->save(); ConfigurableLanguage::createFromLangcode('cs')->save(); $this->installEntitySchema('tmgmt_job'); $this->installEntitySchema('tmgmt_job_item'); $this->installEntitySchema('tmgmt_remote'); $this->installEntitySchema('tmgmt_message'); $this->installEntitySchema('entity_test_rev'); $this->installEntitySchema('entity_test_mulrev'); $this->installEntitySchema('entity_test_mul'); $this->container->get('content_translation.manager')->setEnabled('entity_test_mul', 'entity_test_mul', TRUE); $this->installSchema('system', array('router')); $this->installSchema('node', array('node_access')); \Drupal::moduleHandler()->loadInclude('entity_test', 'install'); entity_test_install(); // Make the test field translatable. $field_storage = FieldStorageConfig::loadByName('entity_test_mul', 'field_test_text'); $field_storage->setCardinality(2); $field_storage->save(); $field = FieldConfig::loadByName('entity_test_mul', 'entity_test_mul', 'field_test_text'); $field->setTranslatable(TRUE); $field->save(); // Add an image field and make it translatable. $this->installEntitySchema('file'); $this->installSchema('file', array('file_usage')); $this->installConfig(array('node')); \Drupal::service('router.builder')->rebuild(); $field_storage = FieldStorageConfig::create(array('field_name' => 'image_test', 'entity_type' => $this->entityTypeId, 'type' => 'image', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'translatable' => TRUE)); $field_storage->save(); FieldConfig::create(array('entity_type' => $this->entityTypeId, 'field_storage' => $field_storage, 'bundle' => $this->entityTypeId, 'label' => $this->image_label = $this->randomMachineName()))->save(); file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg'); $this->image = entity_create('file', array('uri' => 'public://example.jpg')); $this->image->save(); tmgmt_translator_auto_create(\Drupal::service('plugin.manager.tmgmt.translator')->getDefinition('test_translator')); }
protected function setUp() { parent::setUp(); $this->languageManager = $this->container->get('language_manager'); foreach (entity_test_entity_types() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); } } $this->installConfig(array('language')); // Create the test field. module_load_install('entity_test'); entity_test_install(); // Enable translations for the test entity type. $this->state->set('entity_test.translation', TRUE); // Create a translatable test field. $this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name'); // Create an untranslatable test field. $this->untranslatableFieldName = Unicode::strtolower($this->randomMachineName() . '_field_name'); // Create field fields in all entity variations. foreach (entity_test_entity_types() as $entity_type) { FieldStorageConfig::create(array('field_name' => $this->fieldName, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save(); FieldConfig::create(['field_name' => $this->fieldName, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE])->save(); FieldStorageConfig::create(array('field_name' => $this->untranslatableFieldName, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4))->save(); FieldConfig::create(['field_name' => $this->untranslatableFieldName, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE])->save(); } // Create the default languages. $this->installConfig(array('language')); // Create test languages. $this->langcodes = array(); for ($i = 0; $i < 3; ++$i) { $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i)); $this->langcodes[$i] = $language->getId(); $language->save(); } }