View source
<?php
namespace Drupal\Tests\lingotek\Functional\Form;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Tests\lingotek\Functional\LingotekTestBase;
class LingotekSettingsTabContentFormTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
'field_ui',
'image',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('page_title_block', [
'region' => 'content',
'weight' => -5,
]);
$this
->drupalPlaceBlock('local_actions_block', [
'region' => 'content',
'weight' => -10,
]);
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
$this
->drupalLogin($this->rootUser);
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$this
->createImageField('field_image', 'article');
$this
->createImageField('user_picture', 'user', 'user');
}
public function testNoUntranslatableEntitiesAreShown() {
$this
->drupalGet('admin/lingotek/settings');
$this
->assertText('There are no translatable content entities specified');
}
public function testConfigureTranslatableEntityWithFieldsAndSubfields() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
ContentLanguageSettings::loadByEntityTypeBundle('user', 'user')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('user', 'user', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$this
->drupalGet('admin/lingotek/settings');
$this
->assertNoText('There are no translatable content types specified');
$this
->assertNoField('node[article][fields][langcode]');
$this
->assertField('node[article][enabled]');
$this
->assertField('node[article][profiles]');
$this
->assertField('node[article][fields][title]');
$this
->assertField('node[article][fields][body]');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][alt]' => 'alt',
'user[user][enabled]' => 1,
'user[user][fields][user_picture]' => 1,
'user[user][fields][user_picture:properties][alt]' => 'alt',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-enabled');
$this
->assertFieldByName('node[article][profiles]', 'automatic');
$this
->assertFieldChecked('edit-node-article-fields-title');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->assertFieldChecked('edit-node-article-fields-field-image');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$config_data = $this
->config('lingotek.settings')
->getRawData();
$this
->assertTrue($config_data['translate']['entity']['node']['article']['enabled']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['title']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['body']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['field_image']);
$this
->assertEqual($config_data['translate']['entity']['node']['article']['field']['field_image:properties']['alt'], '1');
$this
->assertEqual($config_data['translate']['entity']['node']['article']['field']['field_image:properties']['title'], '0');
$this
->assertFalse(array_key_exists('revision_log', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertEqual('automatic', $config_data['translate']['entity']['node']['article']['profile']);
}
public function testDisableTranslatableEntity() {
$this
->testConfigureTranslatableEntityWithFieldsAndSubfields();
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][alt]' => FALSE,
'node[article][fields][field_image:properties][title]' => 'title',
'user[user][enabled]' => 1,
'user[user][fields][user_picture]' => 1,
'user[user][fields][user_picture:properties][alt]' => FALSE,
'user[user][fields][user_picture:properties][title]' => 'title',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-enabled');
$this
->assertFieldByName('node[article][profiles]', 'automatic');
$this
->assertFieldChecked('edit-node-article-fields-title');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->assertFieldChecked('edit-node-article-fields-field-image');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-title');
$config_data = $this
->config('lingotek.settings')
->getRawData();
$this
->assertTrue($config_data['translate']['entity']['node']['article']['enabled']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['title']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['body']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['field_image']);
$this
->assertEqual($config_data['translate']['entity']['node']['article']['field']['field_image:properties']['alt'], '0');
$this
->assertEqual($config_data['translate']['entity']['node']['article']['field']['field_image:properties']['title'], '1');
$this
->assertFalse(array_key_exists('revision_log', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertEqual('automatic', $config_data['translate']['entity']['node']['article']['profile']);
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => FALSE,
'node[article][fields][field_image]' => FALSE,
'node[article][fields][field_image:properties][alt]' => FALSE,
'node[article][fields][field_image:properties][title]' => 'title',
'user[user][enabled]' => 1,
'user[user][fields][user_picture]' => 1,
'user[user][fields][user_picture:properties][alt]' => FALSE,
'user[user][fields][user_picture:properties][title]' => 'title',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-enabled');
$this
->assertFieldByName('node[article][profiles]', 'automatic');
$this
->assertFieldChecked('edit-node-article-fields-title');
$this
->assertNoFieldChecked('edit-node-article-fields-body');
$this
->assertNoFieldChecked('edit-node-article-fields-field-image');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$config_data = $this
->config('lingotek.settings')
->getRawData();
$this
->assertTrue($config_data['translate']['entity']['node']['article']['enabled']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['title']);
$this
->assertFalse(array_key_exists('body', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertFalse(array_key_exists('field_image', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertFalse(array_key_exists('alt', $config_data['translate']['entity']['node']['article']['field']['field_image:properties']));
$this
->assertEqual($config_data['translate']['entity']['node']['article']['field']['field_image:properties']['title'], '0');
$this
->assertFalse(array_key_exists('revision_log', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertEqual('automatic', $config_data['translate']['entity']['node']['article']['profile']);
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => FALSE,
'node[article][fields][field_image]' => FALSE,
'node[article][fields][field_image:properties][alt]' => FALSE,
'node[article][fields][field_image:properties][title]' => 'title',
'user[user][enabled]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-enabled');
$this
->assertFieldByName('node[article][profiles]', 'automatic');
$this
->assertFieldChecked('edit-node-article-fields-title');
$this
->assertNoFieldChecked('edit-node-article-fields-body');
$this
->assertNoFieldChecked('edit-node-article-fields-field-image');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$this
->assertNoFieldChecked('edit-user-user-enabled');
$this
->assertFieldByName('user[user][profiles]', 'automatic');
$this
->assertFieldChecked('edit-user-user-fields-user-picture');
$this
->assertFieldChecked('edit-user-user-fields-user-pictureproperties-title');
$config_data = $this
->config('lingotek.settings')
->getRawData();
$this
->assertTrue($config_data['translate']['entity']['node']['article']['enabled']);
$this
->assertTrue($config_data['translate']['entity']['node']['article']['field']['title']);
$this
->assertFalse(array_key_exists('body', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertFalse(array_key_exists('field_image', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertFalse(array_key_exists('alt', $config_data['translate']['entity']['node']['article']['field']['field_image:properties']));
$this
->assertEqual($config_data['translate']['entity']['node']['article']['field']['field_image:properties']['title'], '0');
$this
->assertFalse(array_key_exists('revision_log', $config_data['translate']['entity']['node']['article']['field']));
$this
->assertEqual('automatic', $config_data['translate']['entity']['node']['article']['profile']);
$this
->assertFalse($config_data['translate']['entity']['user']['user']['enabled']);
$this
->assertTrue($config_data['translate']['entity']['user']['user']['field']['user_picture']);
$this
->assertEqual($config_data['translate']['entity']['user']['user']['field']['user_picture:properties']['title'], '1');
}
public function testICanDisableFields() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$this
->drupalGet('admin/lingotek/settings');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][alt]' => 'alt',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => FALSE,
'node[article][fields][field_image]' => FALSE,
'node[article][fields][field_image:properties][alt]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertNoFieldChecked('edit-node-article-fields-body');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
}
public function testFieldsAreDisabledInLingotekIfFieldsAreMarkedAsNotTranslatable() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$this
->drupalGet('admin/lingotek/settings');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][alt]' => 'alt',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-fields-title', 'The title field is enabled after enabled for Lingotek translation');
$this
->assertFieldChecked('edit-node-article-fields-body', 'The body field is enabled after enabled for Lingotek translation');
$this
->assertFieldChecked('edit-node-article-fields-field-image', 'The image field is enabled after enabled for Lingotek translation');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-alt', 'The image alt property is enabled after enabled for Lingotek translation');
$edit = [
'entity_types[node]' => TRUE,
'settings[node][article][settings][language][language_alterable]' => TRUE,
'settings[node][article][translatable]' => TRUE,
'settings[node][article][fields][title]' => TRUE,
'settings[node][article][fields][body]' => FALSE,
'settings[node][article][fields][field_image]' => FALSE,
];
$this
->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
$this
->drupalGet('admin/lingotek/settings');
$this
->assertFieldChecked('edit-node-article-fields-title', 'The title field is enabled after other fields were disabled for content translation');
$this
->assertNoFieldById('edit-node-article-fields-body', 'The body field is not present after disabled for content translation');
$this
->assertNoFieldById('edit-node-article-fields-field-image', 'The image field is not present after disabled for content translation');
$this
->assertNoFieldById('edit-node-article-fields-field-imageproperties-alt', 'The image alt property is not present after image was disabled for content translation');
$lingotek_config = \Drupal::service('lingotek.configuration');
$this
->assertFalse($lingotek_config
->isFieldLingotekEnabled('node', 'article', 'body'), 'The body field is disabled after being disabled for content translation');
$this
->assertFalse($lingotek_config
->isFieldLingotekEnabled('node', 'article', 'image'), 'The image field is disabled after being disabled for content translation');
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', FALSE);
$this
->assertFalse($lingotek_config
->isEnabled('node', 'article'), 'The article entity is disabled after being disabled for content translation');
$this
->assertFalse($lingotek_config
->isFieldLingotekEnabled('node', 'article', 'title'), 'The title field is disabled after the entity being disabled for content translation');
}
public function testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$field_storage = FieldStorageConfig::loadByName('node', 'field_image');
$field_storage
->setTranslatable(TRUE)
->save();
$field = FieldConfig::loadByName('node', 'article', 'field_image');
$field
->setTranslatable(FALSE)
->save();
$field_storage = FieldStorageConfig::loadByName('node', 'field_image');
$field = FieldConfig::loadByName('node', 'article', 'field_image');
$this
->assertTrue($field_storage
->isTranslatable(), 'Field storage is translatable.');
$this
->assertFalse($field
->isTranslatable(), 'Field instance is not translatable.');
$this
->drupalGet('admin/lingotek/settings');
$this
->assertNoFieldById('edit-node-article-fields-field-image', '', 'The image field is not present after marked as not translatable.');
$field
->setTranslatable(TRUE)
->save();
$this
->drupalGet('admin/lingotek/settings');
$this
->assertFieldById('edit-node-article-fields-field-image', '', 'The image field is present after marked as translatable.');
}
public function testAddContentTypeAndConfigureLingotekToTranslate() {
$this
->drupalGet('admin/structure/types');
$this
->clickLink('Add content type');
$this
->assertNoFieldChecked('language_configuration[language_alterable]');
$this
->assertNoFieldChecked('language_configuration[content_translation]');
$this
->assertNoFieldChecked('language_configuration[content_translation_for_lingotek]');
$edit = [
'name' => 'Test',
'type' => 'test',
'language_configuration[language_alterable]' => TRUE,
'language_configuration[content_translation]' => TRUE,
'language_configuration[content_translation_for_lingotek]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, 'Save and manage fields');
$this
->assertText('The content type Test has been added.');
$this
->drupalGet('admin/lingotek/settings');
$this
->assertFieldChecked('edit-node-test-enabled');
$this
->assertFieldChecked('edit-node-test-fields-title');
$this
->assertFieldChecked('edit-node-test-fields-body');
$this
->assertNoFieldChecked('edit-node-test-fields-uid');
}
public function testEditContentTypeAndUseLingotekToTranslate() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$this
->drupalGet('admin/structure/types/manage/article');
$edit = [
'language_configuration[language_alterable]' => FALSE,
'language_configuration[content_translation]' => FALSE,
'language_configuration[content_translation_for_lingotek]' => FALSE,
];
$this
->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this
->drupalGet('admin/structure/types/manage/article');
$this
->drupalGet('admin/lingotek/settings');
$this
->assertText('There are no translatable content entities specified');
$edit = [
'language_configuration[language_alterable]' => TRUE,
'language_configuration[content_translation]' => TRUE,
'language_configuration[content_translation_for_lingotek]' => TRUE,
];
$this
->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this
->applyEntityUpdates();
$this
->drupalGet('admin/structure/types/manage/article');
$this
->drupalGet('admin/lingotek/settings');
$this
->assertFieldChecked('edit-node-article-enabled');
$this
->assertFieldChecked('edit-node-article-fields-title');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->assertNoFieldChecked('edit-node-article-fields-uid');
}
public function testCreateFieldAndUseLingotekToTranslateWithBodyField() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$this
->drupalGet('admin/lingotek/settings');
$this
->assertNoFieldChecked('edit-node-article-fields-body');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][body]' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->drupalGet('/admin/config/regional/config-translation/node_fields');
$this
->clickLink(t('Translate'), 0);
$this
->clickLink('Edit');
$this
->assertFieldChecked('edit-translatable-for-lingotek');
$this
->assertNoRaw('Lingotek translation');
$edit = [
'translatable_for_lingotek' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
$this
->clickLink('Edit');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek');
$this
->drupalGet('/admin/lingotek/settings');
$this
->assertNoFieldChecked("edit-node-article-fields-body");
$this
->drupalGet('/admin/config/regional/config-translation/node_fields');
$this
->clickLink(t('Translate'), 0);
$this
->clickLink('Edit');
$edit = [
'translatable_for_lingotek' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
$this
->clickLink('Edit');
$this
->assertFieldChecked('edit-translatable-for-lingotek');
$this
->drupalGet('/admin/lingotek/settings');
$this
->assertFieldChecked("edit-node-article-fields-body");
}
public function testCreateFieldAndUseLingotekToTranslateWithImageProperties() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->applyEntityUpdates();
$this
->drupalGet('admin/lingotek/settings');
$this
->assertNoFieldChecked('edit-node-article-fields-body');
$this
->assertNoFieldChecked('edit-node-article-fields-field-image');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$edit = [
'node[article][enabled]' => 1,
'node[article][profiles]' => 'automatic',
'node[article][fields][title]' => 1,
'node[article][fields][body]' => 1,
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][alt]' => 'alt',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->assertFieldChecked('edit-node-article-fields-field-image');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$edit = [
'node[article][fields][field_image]' => FALSE,
'node[article][fields][field_image:properties][alt]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-fields-body');
$this
->assertNoFieldChecked('edit-node-article-fields-field-image');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$this
->drupalGet('/admin/config/regional/config-translation/node_fields');
$this
->clickLink(t('Translate'), 1);
$this
->clickLink('Edit');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek');
$this
->assertNoFieldChecked('edit-third-party-settings-content-translation-translation-sync-file');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-file');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-alt');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-title');
$edit = [
'translatable_for_lingotek' => 1,
'third_party_settings[content_translation][translation_sync][alt]' => 'alt',
'translatable_for_lingotek_properties_alt' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
$this
->clickLink('Edit');
$this
->assertFieldChecked('edit-translatable-for-lingotek');
$this
->assertNoFieldChecked('edit-third-party-settings-content-translation-translation-sync-file');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-file');
$this
->assertFieldChecked('edit-translatable-for-lingotek-properties-alt');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-title');
$this
->drupalGet('/admin/lingotek/settings');
$this
->assertFieldChecked("edit-node-article-fields-field-image");
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$edit = [
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][file]' => FALSE,
'node[article][fields][field_image:properties][alt]' => FALSE,
'node[article][fields][field_image:properties][title]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$this
->drupalGet('/admin/config/regional/config-translation/node_fields');
$this
->clickLink(t('Translate'), 1);
$this
->clickLink('Edit');
$edit = [
'translatable_for_lingotek' => 1,
'third_party_settings[content_translation][translation_sync][file]' => 'file',
'third_party_settings[content_translation][translation_sync][alt]' => 'alt',
'third_party_settings[content_translation][translation_sync][title]' => 'title',
'translatable_for_lingotek_properties_alt' => 1,
'translatable_for_lingotek_properties_title' => 1,
'translatable_for_lingotek_properties_file' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
$this
->clickLink('Edit');
$this
->assertFieldChecked('edit-translatable-for-lingotek');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-file');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt');
$this
->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title');
$this
->assertFieldChecked('edit-translatable-for-lingotek-properties-file');
$this
->assertFieldChecked('edit-translatable-for-lingotek-properties-alt');
$this
->assertFieldChecked('edit-translatable-for-lingotek-properties-title');
$this
->drupalGet('/admin/lingotek/settings');
$this
->assertFieldChecked("edit-node-article-fields-field-image");
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-file');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertFieldChecked('edit-node-article-fields-field-imageproperties-title');
$edit = [
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][file]' => FALSE,
'node[article][fields][field_image:properties][alt]' => FALSE,
'node[article][fields][field_image:properties][title]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked("edit-node-article-fields-field-image");
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$this
->drupalGet('/admin/config/regional/config-translation/node_fields');
$this
->clickLink(t('Translate'), 1);
$this
->clickLink('Edit');
$edit = [
'translatable_for_lingotek' => 1,
'third_party_settings[content_translation][translation_sync][alt]' => FALSE,
'third_party_settings[content_translation][translation_sync][title]' => FALSE,
'third_party_settings[content_translation][translation_sync][file]' => FALSE,
'translatable_for_lingotek_properties_alt' => 1,
'translatable_for_lingotek_properties_title' => 1,
'translatable_for_lingotek_properties_file' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
$this
->clickLink('Edit');
$this
->assertFieldChecked('edit-translatable-for-lingotek');
$this
->assertNoFieldChecked('edit-third-party-settings-content-translation-translation-sync-file');
$this
->assertNoFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt');
$this
->assertNoFieldChecked('edit-third-party-settings-content-translation-translation-sync-title');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-file');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-alt');
$this
->assertNoFieldChecked('edit-translatable-for-lingotek-properties-title');
$this
->drupalGet('/admin/lingotek/settings');
$this
->assertFieldChecked("edit-node-article-fields-field-image");
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
$edit = [
'node[article][fields][field_image]' => 1,
'node[article][fields][field_image:properties][alt]' => FALSE,
'node[article][fields][field_image:properties][title]' => FALSE,
'node[article][fields][field_image:properties][file]' => FALSE,
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-alt');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-title');
$this
->assertNoFieldChecked('edit-node-article-fields-field-imageproperties-file');
}
public function testContentTypesAreNotDisabledIfThereAreLotsOfContentTypes() {
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->saveLingotekContentTranslationSettingsForNodeTypes();
foreach (range(1, 150) as $i) {
$this
->drupalCreateContentType([
'type' => 'content_type_' . $i,
'name' => 'Content Type ' . $i,
]);
ContentLanguageSettings::loadByEntityTypeBundle('node', 'content_type_' . $i)
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'content_type_' . $i, TRUE);
}
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->drupalGet('admin/lingotek/settings');
$this
->assertFieldChecked('edit-node-article-readonly-enabled');
$this
->assertFieldByName('node[article][profiles]', 'automatic');
$edit = [
'node[article][profiles]' => 'manual',
];
$this
->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');
$this
->assertFieldChecked('edit-node-article-readonly-enabled');
$this
->assertFieldByName('node[article][profiles]', 'manual');
}
}