You are here

public function LingotekFieldBodyTranslationTest::testEditedFieldBodyTranslation in Lingotek Translation 8

Tests that a config can be translated after edited.

File

src/Tests/LingotekFieldBodyTranslationTest.php, line 111

Class

LingotekFieldBodyTranslationTest
Tests translating a field.

Namespace

Drupal\lingotek\Tests

Code

public function testEditedFieldBodyTranslation() {

  // We need a config with translations first.
  $this
    ->testFieldTranslation();

  // Add a language so we can check that it's not marked as dirty if there are
  // no translations.
  ConfigurableLanguage::createFromLangcode('eu')
    ->setThirdPartySetting('lingotek', 'locale', 'eu_ES')
    ->save();

  // Edit the field.
  $edit = [
    'label' => 'Contents',
  ];
  $this
    ->drupalPostForm('/admin/structure/types/manage/article/fields/node.article.body', $edit, t('Save settings'));
  $this
    ->assertText('Saved Contents configuration.');
  $this
    ->clickLink(t('Translate'));

  // Check the status is not edited for Vasque, but available to request
  // translation.
  $this
    ->assertLinkByHref('/admin/lingotek/config/request/node_fields/node.article.body/eu_ES');
  $this
    ->clickLink(t('Request translation'), 1);
  $this
    ->assertText(t('Translation to es_MX requested successfully'));
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.added_target_locale'));

  // Recheck status.
  $this
    ->clickLink('Check Download');
  $this
    ->assertText('Translation to es_MX status checked successfully');

  // Download the translation.
  $this
    ->clickLink('Download');
  $this
    ->assertText('Translation to es_MX downloaded successfully');
}