Verified Commit 357b600b authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3111550 by Primsi, Berdir, smustgrave: Test that new fields are...

Issue #3111550 by Primsi, Berdir, smustgrave: Test that new fields are translatable when re-using existing storage but not translatable when added from the UI
parent 932ce644
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -305,6 +305,9 @@ public function testFieldTranslatableSettingsUI() {
    $this->assertSession()->fieldDisabled('edit-translatable');
    $this->assertSession()->pageTextContains('To configure translation for this field, enable language support for this type.');

    // 'Users may translate this field' should be unchecked by default.
    $this->assertSession()->checkboxNotChecked('translatable');

    // Tests that field has translatable setting if bundle is translatable.
    // Note: this field is not translatable when enable bundle translatability.
    $edit = [
+22 −0
Original line number Diff line number Diff line
@@ -1040,4 +1040,26 @@ public function entityTypesProvider() {
    ];
  }

  /**
   * Test translation defaults.
   */
  public function testTranslationDefaults() {
    $this->createField();
    $field_storage = FieldStorageConfig::loadByName('node', 'field_' . $this->fieldNameInput);
    $this->assertTrue($field_storage->isTranslatable(), 'Field storage translatable.');

    $field = FieldConfig::loadByName('node', $this->contentType, 'field_' . $this->fieldNameInput);
    $this->assertFalse($field->isTranslatable(), 'Field instance should not be translatable by default.');

    // Add a new field based on an existing field.
    $this->drupalCreateContentType(['type' => 'additional', 'name' => 'Additional type']);
    $this->fieldUIAddExistingField("admin/structure/types/manage/additional", $this->fieldName, 'Additional type');

    $field_storage = FieldStorageConfig::loadByName('node', 'field_' . $this->fieldNameInput);
    $this->assertTrue($field_storage->isTranslatable(), 'Field storage translatable.');

    $field = FieldConfig::loadByName('node', 'additional', 'field_' . $this->fieldNameInput);
    $this->assertFalse($field->isTranslatable(), 'Field instance should not be translatable by default.');
  }

}