public function LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 4.0.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.0.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.1.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.2.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.3.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.4.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.6.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.7.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
- 3.8.x tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekSettingsTabContentFormTest::testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable()
File
- tests/
src/ Functional/ Form/ LingotekSettingsTabContentFormTest.php, line 376
Class
- LingotekSettingsTabContentFormTest
- Tests the Lingotek content settings form.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testFieldsAreNotAvailableIfTranslatableEvenIfStorageIsTranslatable() {
// 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
->applyEntityUpdates();
// Ensure field storage is translatable.
$field_storage = FieldStorageConfig::loadByName('node', 'field_image');
$field_storage
->setTranslatable(TRUE)
->save();
// Ensure field instance is not translatable.
$field = FieldConfig::loadByName('node', 'article', 'field_image');
$field
->setTranslatable(FALSE)
->save();
// Ensure changes were saved correctly.
$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.');
// Get the form and check the field is not available, even if the storage
// is 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.');
// Make the field translatable again.
$field
->setTranslatable(TRUE)
->save();
// If the field is translatable, the field is available again.
$this
->drupalGet('admin/lingotek/settings');
$this
->assertFieldById('edit-node-article-fields-field-image', '', 'The image field is present after marked as translatable.');
}