You are here

public function ConfigTranslationUiTest::testSourceAndTargetLanguage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php \Drupal\config_translation\Tests\ConfigTranslationUiTest::testSourceAndTargetLanguage()

Tests source and target language edge cases.

File

core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php, line 511
Contains \Drupal\config_translation\Tests\ConfigTranslationUiTest.

Class

ConfigTranslationUiTest
Translate settings and entities to various languages.

Namespace

Drupal\config_translation\Tests

Code

public function testSourceAndTargetLanguage() {
  $this
    ->drupalLogin($this->adminUser);

  // Loading translation page for not-specified language (und)
  // should return 403.
  $this
    ->drupalGet('admin/config/system/site-information/translate/und/add');
  $this
    ->assertResponse(403);

  // Check the source language doesn't have 'Add' or 'Delete' link and
  // make sure source language edit goes to original configuration page
  // not the translation specific edit page.
  $this
    ->drupalGet('admin/config/system/site-information/translate');
  $this
    ->assertNoLinkByHref('admin/config/system/site-information/translate/en/edit');
  $this
    ->assertNoLinkByHref('admin/config/system/site-information/translate/en/add');
  $this
    ->assertNoLinkByHref('admin/config/system/site-information/translate/en/delete');
  $this
    ->assertLinkByHref('admin/config/system/site-information');

  // Translation addition to source language should return 403.
  $this
    ->drupalGet('admin/config/system/site-information/translate/en/add');
  $this
    ->assertResponse(403);

  // Translation editing in source language should return 403.
  $this
    ->drupalGet('admin/config/system/site-information/translate/en/edit');
  $this
    ->assertResponse(403);

  // Translation deletion in source language should return 403.
  $this
    ->drupalGet('admin/config/system/site-information/translate/en/delete');
  $this
    ->assertResponse(403);

  // Set default language of site information to not-specified language (und).
  $this
    ->config('system.site')
    ->set('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED)
    ->save();

  // Make sure translation tab does not exist on the configuration page.
  $this
    ->drupalGet('admin/config/system/site-information');
  $this
    ->assertNoLinkByHref('admin/config/system/site-information/translate');

  // If source language is not specified, translation page should be 403.
  $this
    ->drupalGet('admin/config/system/site-information/translate');
  $this
    ->assertResponse(403);
}