You are here

function LanguageSwitchingTest::testLanguageBlock in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/Tests/LanguageSwitchingTest.php \Drupal\language\Tests\LanguageSwitchingTest::testLanguageBlock()

Functional tests for the language switcher block.

File

core/modules/language/src/Tests/LanguageSwitchingTest.php, line 41
Contains \Drupal\language\Tests\LanguageSwitchingTest.

Class

LanguageSwitchingTest
Functional tests for the language switching feature.

Namespace

Drupal\language\Tests

Code

function testLanguageBlock() {

  // Add language.
  $edit = array(
    'predefined_langcode' => 'fr',
  );
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));

  // Set the native language name.
  $this
    ->saveNativeLanguageName('fr', 'français');

  // Enable URL language detection and selection.
  $edit = array(
    'language_interface[enabled][language-url]' => '1',
  );
  $this
    ->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));

  // Enable the language switching block.
  $block = $this
    ->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array(
    'id' => 'test_language_block',
    // Ensure a 2-byte UTF-8 sequence is in the tested output.
    'label' => $this
      ->randomMachineName(8) . '×',
  ));
  $this
    ->doTestLanguageBlockAuthenticated($block
    ->label());
  $this
    ->doTestLanguageBlockAnonymous($block
    ->label());
}