function AdminTest::testUserSettings

Same name and namespace in other branches
  1. main core/themes/admin/tests/src/Functional/AdminTest.php \Drupal\Tests\admin\Functional\AdminTest::testUserSettings()

Test user settings.

File

core/themes/admin/tests/src/Functional/AdminTest.php, line 102

Class

AdminTest
Tests the Admin theme.

Namespace

Drupal\Tests\admin\Functional

Code

public function testUserSettings() : void {
  \Drupal::configFactory()->getEditable('admin.settings')
    ->set('show_user_theme_settings', TRUE)
    ->save();
  $user1 = $this->createUser();
  $this->drupalLogin($user1);
  // Change something on the logged in user form.
  $this->assertStringContainsString('"dark_mode":"0"', $this->drupalGet($user1->toUrl('edit-form')));
  $this->submitForm([
    'enable_user_settings' => TRUE,
    'enable_dark_mode' => '1',
  ], 'Save');
  $this->assertStringContainsString('"dark_mode":"1"', $this->drupalGet($user1->toUrl('edit-form')));
  // Login as admin.
  $this->drupalLogin($this->rootUser);
  $this->assertStringContainsString('"dark_mode":"0"', $this->drupalGet('edit-form'));
}

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