You are here

public function LingotekConfigObjectTranslationPreSaveHookTest::testRssPublishingTranslation in Lingotek Translation 3.1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekConfigObjectTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigObjectTranslationPreSaveHookTest::testRssPublishingTranslation()
  2. 3.0.x tests/src/Functional/LingotekConfigObjectTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigObjectTranslationPreSaveHookTest::testRssPublishingTranslation()
  3. 3.2.x tests/src/Functional/LingotekConfigObjectTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigObjectTranslationPreSaveHookTest::testRssPublishingTranslation()

Tests that rss publishing settings can be translated.

File

tests/src/Functional/LingotekConfigObjectTranslationPreSaveHookTest.php, line 39

Class

LingotekConfigObjectTranslationPreSaveHookTest
Tests the Lingotek config object translation pre save hook.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testRssPublishingTranslation() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet('admin/config/services/rss-publishing');
  $edit = [
    'feed_description' => 'Llamas feed description',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save configuration');
  $this
    ->goToConfigBulkManagementForm();
  $this
    ->clickLink('EN', 2);

  // Check that Llamas is replaced via hook_lingotek_config_object_document_upload().
  // @see lingotek_test_lingotek_config_object_document_upload()
  $data = json_decode(\Drupal::state()
    ->get('lingotek.uploaded_content', '[]'), TRUE);
  $this
    ->verbose(var_export($data, TRUE));
  $this
    ->assertEqual($data['system.rss']['channel.description'], 'Cats feed description');

  // Translate the config using Lingotek.
  $this
    ->clickLink('ES');
  $this
    ->clickLink('ES');
  $this
    ->clickLink('ES');

  // Check that Gatos is replaced via hook_lingotek_config_object_translation_presave().
  // @see lingotek_test_lingotek_config_object_translation_presave()
  $this
    ->drupalGet("admin/config/services/rss-publishing/translate/es/edit");
  $this
    ->assertFieldByName("translation[config_names][system.rss][channel][description]", 'Perros alimentados descripción');

  // ToDo: See core issue https://www.drupal.org/project/drupal/issues/3019793.
  // $this->drupalGet('es/rss.xml');
  // $this->assertRaw('Perros alimentados descripción');
}