public function LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable in Lingotek Translation 8
File
- src/Tests/Form/LingotekSettingsTabContentFormTest.php, line 234
Class
- LingotekSettingsTabContentFormTest
- Tests the Lingotek content settings form.
Namespace
Drupal\lingotek\Tests\Form
Code
public function testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable() {
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();
$this
->rebuildContainer();
\Drupal::service('entity.definition_update_manager')
->applyUpdates();
$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.');
}