protected function LingotekNodeExistingBulkTranslationTest::setUp in Lingotek Translation 8
Throws
\Exception
Overrides LingotekTestBase::setUp
File
- src/
Tests/ LingotekNodeExistingBulkTranslationTest.php, line 33
Class
- LingotekNodeExistingBulkTranslationTest
- Tests translating a node using the bulk management form.
Namespace
Drupal\lingotek\TestsCode
protected function setUp() {
parent::setUp();
// Login as admin.
$this
->drupalLogin($this->rootUser);
// Create Article node types.
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
// Create a node.
$edit = array();
$edit['title[0][value]'] = 'Llamas are cool';
$edit['body[0][value]'] = 'Llamas are very cool';
$this
->drupalPostForm('node/add/article', $edit, t('Save and publish'));
// Add a language.
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->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::entityManager()
->clearCachedDefinitions();
\Drupal::service('entity.definition_update_manager')
->applyUpdates();
// Rebuild the container so that the new languages are picked up by services
// that hold a list of languages.
$this
->rebuildContainer();
/** @var NodeInterface $node */
$node = Node::load(1);
$node
->addTranslation('es', [
'title' => 'Llamas are cool ES',
'body' => 'Llamas are very cool ES',
]);
$node
->save();
$this
->drupalGet('node/1/translations');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
];
$this
->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-content-form');
}