Same filename and directory in other branches
- 8.9.x core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
- 9 core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
Namespace
Drupal\Tests\system\Functional\Render
File
core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\system\Functional\Render;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Tests\BrowserTestBase;
class AjaxPageStateTest extends BrowserTestBase {
protected static $modules = [
'node',
'views',
];
protected $defaultTheme = 'stark';
protected $adminUser;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser(array_keys(\Drupal::service('user.permissions')
->getPermissions()));
$this
->drupalLogin($this->adminUser);
}
public function testLibrariesAvailable() {
$this
->drupalGet('node', []);
$this
->assertSession()
->responseContains('/core/misc/active-link.js');
$this
->assertSession()
->responseContains('/core/misc/drupalSettingsLoader.js');
}
public function testDrupalSettingsIsNotLoaded() {
$this
->drupalGet('node', [
'query' => [
'ajax_page_state' => [
'libraries' => UrlHelper::compressQueryParameter('core/drupalSettings'),
],
],
]);
$this
->assertSession()
->responseNotContains('/core/misc/drupalSettingsLoader.js');
$this
->assertSession()
->responseContains('/core/misc/active-link.js');
}
public function testMultipleLibrariesAreNotLoaded() {
$this
->drupalGet('node', [
'query' => [
'ajax_page_state' => [
'libraries' => UrlHelper::compressQueryParameter('core/drupal,core/drupalSettings'),
],
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseNotContains('/core/misc/drupal.js');
$this
->assertSession()
->responseNotContains('/core/misc/drupalSettingsLoader.js');
$this
->drupalGet('node');
$this
->assertSession()
->responseContains('/core/misc/drupal.js');
$this
->assertSession()
->responseContains('/core/misc/drupalSettingsLoader.js');
}
}
Classes
Name |
Description |
AjaxPageStateTest |
Performs tests for the effects of the ajax_page_state query parameter. |