protected function LingotekNodeEmbeddingTagsTranslationTest::setUp in Lingotek Translation 3.1.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 4.0.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.0.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.2.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.3.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.4.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.5.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.6.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.7.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
- 3.8.x tests/src/Functional/LingotekNodeEmbeddingTagsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeEmbeddingTagsTranslationTest::setUp()
Overrides LingotekTestBase::setUp
File
- tests/
src/ Functional/ LingotekNodeEmbeddingTagsTranslationTest.php, line 44
Class
- LingotekNodeEmbeddingTagsTranslationTest
- Tests translating a node with multiple locales embedding another entity.
Namespace
Drupal\Tests\lingotek\FunctionalCode
protected function setUp() : void {
parent::setUp();
// Place the actions and title block.
$this
->drupalPlaceBlock('page_title_block', [
'id' => 'block_1',
'label' => 'Title block',
'region' => 'content',
'weight' => -5,
]);
$this
->drupalPlaceBlock('local_tasks_block', [
'id' => 'block_2',
'label' => 'Local tasks block',
'region' => 'content',
'weight' => -10,
]);
// Create Article node types.
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$this
->createImageField('field_image', 'article');
$this->vocabulary = $this
->createVocabulary();
$handler_settings = [
'target_bundles' => [
$this->vocabulary
->id() => $this->vocabulary
->id(),
],
'auto_create' => TRUE,
];
$this
->createEntityReferenceField('node', 'article', 'field_tags', 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
EntityFormDisplay::load('node.article.default')
->setComponent('field_tags', [
'type' => 'entity_reference_autocomplete_tags',
])
->save();
EntityViewDisplay::load('node.article.default')
->setComponent('field_tags')
->save();
// Add locales.
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_ES')
->save();
ConfigurableLanguage::createFromLangcode('es-ar')
->setThirdPartySetting('lingotek', 'locale', 'es_AR')
->save();
// Enable translation for the current entity type and ensure the change is
// picked up.
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
\Drupal::service('content_translation.manager')
->setEnabled('taxonomy_term', $this->vocabulary
->id(), TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
// Rebuild the container so that the new languages are picked up by services
// that hold a list of languages.
$this
->rebuildContainer();
$bundle = $this->vocabulary
->id();
$this
->saveLingotekContentTranslationSettings([
'node' => [
'article' => [
'profiles' => 'automatic',
'fields' => [
'title' => 1,
'body' => 1,
'field_image' => [
'alt',
],
'field_tags' => 1,
],
],
],
'taxonomy_term' => [
$bundle => [
'profiles' => 'manual',
'fields' => [
'name' => 1,
'description' => 1,
],
],
],
]);
// This is a hack for avoiding writing different lingotek endpoint mocks.
\Drupal::state()
->set('lingotek.uploaded_content_type', 'node+taxonomy_term');
}