You are here

public function ContentTranslationSettingsTest::testAccountLanguageSettingsUI in Drupal 9

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

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()
    ->pageTextContains('The configuration options have been saved.');
}