function LanguageUILanguageNegotiationTest::testDisableLanguageSwitcher

Same name in other branches
  1. 8.9.x core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::testDisableLanguageSwitcher()
  2. 10 core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::testDisableLanguageSwitcher()
  3. 11.x core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php \Drupal\Tests\language\Functional\LanguageUILanguageNegotiationTest::testDisableLanguageSwitcher()

Tests if the language switcher block gets deleted when a language type has been made not configurable.

File

core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php, line 590

Class

LanguageUILanguageNegotiationTest
Tests the language UI for language switching.

Namespace

Drupal\Tests\language\Functional

Code

public function testDisableLanguageSwitcher() {
    $block_id = 'test_language_block';
    // Enable the language switcher block.
    $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_CONTENT, [
        'id' => $block_id,
    ]);
    // Check if the language switcher block has been created.
    $block = Block::load($block_id);
    $this->assertNotEmpty($block, 'Language switcher block was created.');
    // Make sure language_content is not configurable.
    $edit = [
        'language_content[configurable]' => FALSE,
    ];
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm($edit, 'Save settings');
    $this->assertSession()
        ->statusCodeEquals(200);
    // Check if the language switcher block has been removed.
    $block = Block::load($block_id);
    $this->assertNull($block, 'Language switcher block was removed.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.