function AjaxTest::testAjaxWithAdminRoute

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::testAjaxWithAdminRoute()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::testAjaxWithAdminRoute()
  3. 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::testAjaxWithAdminRoute()

File

core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php, line 27

Class

AjaxTest
Tests AJAX responses.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

public function testAjaxWithAdminRoute() : void {
    \Drupal::service('theme_installer')->install([
        'stable9',
        'claro',
    ]);
    $theme_config = \Drupal::configFactory()->getEditable('system.theme');
    $theme_config->set('admin', 'claro');
    $theme_config->set('default', 'stable9');
    $theme_config->save();
    $account = $this->drupalCreateUser([
        'view the administration theme',
    ]);
    $this->drupalLogin($account);
    // First visit the site directly via the URL. This should render it in the
    // admin theme.
    $this->drupalGet('admin/ajax-test/theme');
    $assert = $this->assertSession();
    $assert->pageTextContains('Current theme: claro');
    // Now click the modal, which should use the front-end theme.
    $this->drupalGet('ajax-test/dialog');
    $assert->pageTextNotContains('Current theme: stable9');
    $this->clickLink('Link 8 (ajax)');
    $assert->assertWaitOnAjaxRequest();
    $assert->pageTextContains('Current theme: stable9');
    $assert->pageTextNotContains('Current theme: claro');
}

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