function AjaxPageStateTest::testMultipleLibrariesAreNotLoaded

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php \Drupal\Tests\system\Functional\Render\AjaxPageStateTest::testMultipleLibrariesAreNotLoaded()
  2. 8.9.x core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php \Drupal\Tests\system\Functional\Render\AjaxPageStateTest::testMultipleLibrariesAreNotLoaded()
  3. 10 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 94

Class

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

Namespace

Drupal\Tests\system\Functional\Render

Code

public function testMultipleLibrariesAreNotLoaded() : void {
    $this->drupalGet('node', [
        'query' => [
            'ajax_page_state' => [
                'libraries' => UrlHelper::compressQueryParameter('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.