protected function LingotekNodeWithLinkTranslationTest::setUp in Lingotek Translation 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 4.0.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.1.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.2.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.3.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.4.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.5.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.6.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.7.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
- 3.8.x tests/src/Functional/LingotekNodeWithLinkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeWithLinkTranslationTest::setUp()
Overrides LingotekTestBase::setUp
File
- tests/
src/ Functional/ LingotekNodeWithLinkTranslationTest.php, line 36
Class
- LingotekNodeWithLinkTranslationTest
- Tests translating a node that contains a link field.
Namespace
Drupal\Tests\lingotek\FunctionalCode
protected function setUp() : void {
parent::setUp();
// Create Article node types.
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
// Create a link field.
// Create a field with settings to validate.
$fieldStorage = \Drupal::entityTypeManager()
->getStorage('field_storage_config')
->create([
'field_name' => $this->field_name,
'entity_type' => 'node',
'type' => 'link',
]);
$fieldStorage
->save();
$field = \Drupal::entityTypeManager()
->getStorage('field_config')
->create([
'field_storage' => $fieldStorage,
'bundle' => 'article',
'settings' => [
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
],
]);
$field
->save();
EntityFormDisplay::load('node.article.default')
->setComponent($this->field_name, [
'type' => 'link_default',
])
->save();
EntityViewDisplay::load('node.article.default')
->setComponent($this->field_name, [
'type' => 'link',
])
->save();
// Place the actions and title block.
$this
->drupalPlaceBlock('local_tasks_block');
$this
->drupalPlaceBlock('page_title_block');
// 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_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();
$this
->saveLingotekContentTranslationSettings([
'node' => [
'article' => [
'profiles' => 'automatic',
'fields' => [
'title' => 1,
'body' => 1,
$this->field_name => 1,
],
],
],
]);
}