protected function LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings in Lingotek Translation 3.1.x
Same name and namespace in other branches
- 8.2 tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 4.0.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.0.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.2.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.3.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.4.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.5.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.6.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.7.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- 3.8.x tests/src/FunctionalJavascript/LingotekFunctionalJavascriptTestBase.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
Save Lingotek content translation settings.
Example:
$this
->saveLingotekContentTranslationSettings([
'node' => [
'article' => [
'profiles' => 'automatic',
'fields' => [
'title' => 1,
'body' => 1,
],
'moderation' => [
'upload_status' => 'draft',
'download_transition' => 'request_review',
],
],
],
'paragraph' => [
'image_text' => [
'fields' => [
'field_image_demo' => [
'title',
'alt',
],
'field_text_demo' => 1,
],
],
],
]);
Parameters
array $settings: The settings we want to save.
4 calls to LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettings()
- LingotekFunctionalJavascriptTestBase::saveLingotekContentTranslationSettingsForNodeTypes in tests/
src/ FunctionalJavascript/ LingotekFunctionalJavascriptTestBase.php - Save Lingotek translation settings for node types.
- LingotekNodeParagraphsTranslationTest::setUp in tests/
src/ FunctionalJavascript/ LingotekNodeParagraphsTranslationTest.php - LingotekSettingsContentSingleFormTest::testWhenDisabledAndEnabledBackNodeArticleFieldsAreKept in tests/
src/ FunctionalJavascript/ LingotekSettingsContentSingleFormTest.php - LingotekSettingsTabContentFormTest::testWhenDisabledAndEnabledBackNodeArticleFieldsAreKept in tests/
src/ FunctionalJavascript/ LingotekSettingsTabContentFormTest.php
File
- tests/
src/ FunctionalJavascript/ LingotekFunctionalJavascriptTestBase.php, line 222
Class
Namespace
Drupal\Tests\lingotek\FunctionalJavascriptCode
protected function saveLingotekContentTranslationSettings($settings) {
$this
->drupalGet('/admin/lingotek/settings');
$page = $this
->getSession()
->getPage();
$contentTabDetails = $page
->find('css', '#edit-parent-details');
$contentTabDetails
->click();
foreach ($settings as $entity_type => $entity_type_settings) {
$entityTabDetails = $page
->find('css', '#edit-entity-' . str_replace('_', '-', $entity_type));
$entityTabDetails
->click();
foreach ($entity_type_settings as $bundle_id => $bundle_settings) {
/** @var \Drupal\Core\Field\FieldDefinitionInterface[] $field_definitions */
$field_definitions = \Drupal::service('entity_field.manager')
->getFieldDefinitions($entity_type, $bundle_id);
$fieldEnabled = $page
->find('css', '#edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-enabled');
$fieldEnabled
->click();
$this
->assertSession()
->assertWaitOnAjaxRequest();
if (isset($bundle_settings['profiles']) && $bundle_settings['profiles'] !== NULL) {
$page
->selectFieldOption('edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-profiles', $bundle_settings['profiles']);
}
$fieldsCheckboxes = $page
->findAll('css', '#container-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . ' input[type="checkbox"]');
$propertiesCheckboxes = $page
->findAll('css', 'input[type="checkbox"] .field-property-checkbox');
/** @var \Behat\Mink\Element\NodeElement $fieldCheckbox */
foreach ($fieldsCheckboxes as $fieldCheckbox) {
if ($fieldCheckbox
->isChecked()) {
$fieldCheckbox
->click();
}
}
foreach ($propertiesCheckboxes as $propertyCheckbox) {
if ($propertyCheckbox
->isChecked()) {
$propertyCheckbox
->click();
}
}
foreach ($bundle_settings['fields'] as $field_id => $field_properties) {
$field_definition = $field_definitions[$field_id];
$field_type_definition = \Drupal::service('plugin.manager.field.field_type')
->getDefinition($field_definition
->getType());
$fieldElementId = 'edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-fields-' . str_replace('_', '-', $field_id);
$fieldCheckbox = $page
->find('css', '#' . $fieldElementId);
$fieldCheckbox
->click();
if (is_array($field_properties)) {
$column_groups = $field_type_definition['column_groups'];
$properties = [];
foreach ($column_groups as $property_id => $property) {
if (isset($property['translatable']) && $property['translatable']) {
$property_definitions = $field_type_definition['class']::propertyDefinitions($field_definition
->getFieldStorageDefinition());
if (isset($property_definitions[$property_id])) {
$properties[$property_id] = $property_id;
}
}
}
// Disable all properties.
foreach ($properties as $field_property) {
$propertyElementId = 'edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-fields-' . str_replace('_', '-', $field_id) . 'properties-' . str_replace('_', '-', $field_property);
$propertyCheckbox = $page
->find('css', '#' . $propertyElementId);
if ($propertyCheckbox
->isChecked()) {
$propertyCheckbox
->click();
}
}
foreach ($field_properties as $field_property) {
$propertyElementId = 'edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-fields-' . str_replace('_', '-', $field_id) . 'properties-' . str_replace('_', '-', $field_property);
$propertyCheckbox = $page
->find('css', '#' . $propertyElementId);
if (!$propertyCheckbox
->isChecked()) {
$propertyCheckbox
->click();
}
}
}
}
if (isset($bundle_settings['moderation']) && $bundle_settings['moderation'] !== NULL) {
$page
->selectFieldOption('edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-moderation-upload-status', $bundle_settings['moderation']['upload_status']);
$page
->selectFieldOption('edit-' . str_replace('_', '-', $entity_type) . '-' . str_replace('_', '-', $bundle_id) . '-moderation-download-transition', $bundle_settings['moderation']['download_transition']);
}
}
}
$this
->drupalPostForm(NULL, [], 'Save', [], 'lingoteksettings-tab-content-form');
}