You are here

public function ConfigTranslationUiTest::testSourceAndTargetLanguage in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testSourceAndTargetLanguage()
  2. 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testSourceAndTargetLanguage()

Tests source and target language edge cases.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php, line 549

Class

ConfigTranslationUiTest
Translate settings and entities to various languages.

Namespace

Drupal\Tests\config_translation\Functional

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
    ->assertSession()
    ->statusCodeEquals(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
    ->assertSession()
    ->statusCodeEquals(403);

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

  // Translation deletion in source language should return 403.
  $this
    ->drupalGet('admin/config/system/site-information/translate/en/delete');
  $this
    ->assertSession()
    ->statusCodeEquals(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
    ->assertSession()
    ->statusCodeEquals(403);
}