function ContentTranslationSettingsTest::testAccountLanguageSettingsUI

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

Tests the language settings checkbox on account settings page.

File

core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php, line 243

Class

ContentTranslationSettingsTest
Tests the content translation settings UI.

Namespace

Drupal\Tests\content_translation\Functional

Code

public function testAccountLanguageSettingsUI() {
    // Make sure the checkbox is available and not checked by default.
    $this->drupalGet('admin/config/people/accounts');
    $this->assertSession()
        ->fieldExists('language[content_translation]');
    $this->assertSession()
        ->checkboxNotChecked('edit-language-content-translation');
    $edit = [
        'language[content_translation]' => TRUE,
    ];
    $this->drupalGet('admin/config/people/accounts');
    $this->submitForm($edit, 'Save configuration');
    $this->drupalGet('admin/config/people/accounts');
    $this->assertSession()
        ->checkboxChecked('edit-language-content-translation');
    // Make sure account settings can be saved.
    $this->drupalGet('admin/config/people/accounts');
    $this->submitForm([
        'anonymous' => 'Save me please!',
    ], 'Save configuration');
    $this->assertSession()
        ->fieldValueEquals('anonymous', 'Save me please!');
    $this->assertSession()
        ->statusMessageContains('The configuration options have been saved.', 'status');
}

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