You are here

public function LanguageUILanguageNegotiationTest::testDisableLanguageSwitcher in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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 584

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.');
}