function AjaxPageStateTest::testDrupalSettingsIsNotLoaded

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php \Drupal\Tests\system\Functional\Render\AjaxPageStateTest::testDrupalSettingsIsNotLoaded()
  2. 11.x core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php \Drupal\Tests\system\Functional\Render\AjaxPageStateTest::testDrupalSettingsIsNotLoaded()

Give ajax_page_state[libraries]=core/drupalSettings to exclude the library.

When called with ajax_page_state[libraries]=core/drupalSettings the library should be excluded as it is already loaded. This should not affect other libraries so test if active-link is still available.

File

core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php, line 67

Class

AjaxPageStateTest
Performs tests for the effects of the ajax_page_state query parameter.

Namespace

Drupal\Tests\system\Functional\Render

Code

public function testDrupalSettingsIsNotLoaded() {
    $this->drupalGet('node', [
        "query" => [
            'ajax_page_state' => [
                'libraries' => 'core/drupalSettings',
            ],
        ],
    ]);
    // The drupalSettings library from core should be excluded from loading.
    $this->assertSession()
        ->responseNotContains('/core/misc/drupalSettingsLoader.js');
    // The active-link library from core should be loaded.
    $this->assertSession()
        ->responseContains('/core/misc/active-link.js');
}

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