function AjaxPageStateTest::testMultipleLibrariesAreNotLoaded

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

Tests if multiple libraries can be excluded.

The ajax_page_state[libraries] should be able to support multiple libraries comma separated.

File

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

Class

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

Namespace

Drupal\Tests\system\Functional\Render

Code

public function testMultipleLibrariesAreNotLoaded() {
    $this->drupalGet('node', [
        'query' => [
            'ajax_page_state' => [
                'libraries' => 'core/drupal,core/drupalSettings',
            ],
        ],
    ]);
    $this->assertSession()
        ->statusCodeEquals(200);
    // The drupal library from core should be excluded from loading.
    $this->assertSession()
        ->responseNotContains('/core/misc/drupal.js');
    // The drupalSettings library from core should be excluded from loading.
    $this->assertSession()
        ->responseNotContains('/core/misc/drupalSettingsLoader.js');
    $this->drupalGet('node');
    // The drupal library from core should be included in loading.
    $this->assertSession()
        ->responseContains('/core/misc/drupal.js');
    // The drupalSettings library from core should be included in loading.
    $this->assertSession()
        ->responseContains('/core/misc/drupalSettingsLoader.js');
}

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