AjaxPageStateTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Render;
use Drupal\Tests\BrowserTestBase;
class AjaxPageStateTest extends BrowserTestBase {
public static $modules = [
'node',
'views',
];
protected $defaultTheme = 'stark';
protected $adminUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser(array_keys(\Drupal::service('user.permissions')
->getPermissions()));
$this
->drupalLogin($this->adminUser);
}
public function testLibrariesAvailable() {
$this
->drupalGet('node', []);
$this
->assertRaw('/core/assets/vendor/html5shiv/html5shiv.min.js', 'The html5shiv library from core should be loaded.');
$this
->assertRaw('/core/misc/drupalSettingsLoader.js', 'The drupalSettings library from core should be loaded.');
}
public function testHtml5ShivIsNotLoaded() {
$this
->drupalGet('node', [
"query" => [
'ajax_page_state' => [
'libraries' => 'core/html5shiv',
],
],
]);
$this
->assertNoRaw('/core/assets/vendor/html5shiv/html5shiv.min.js', 'The html5shiv library from core should be excluded from loading');
$this
->assertRaw('/core/misc/drupalSettingsLoader.js', 'The drupalSettings library from core should be loaded.');
}
public function testMultipleLibrariesAreNotLoaded() {
$this
->drupalGet('node', [
'query' => [
'ajax_page_state' => [
'libraries' => 'core/html5shiv,core/drupalSettings',
],
],
]);
$this
->assertResponse(200);
$this
->assertNoRaw('/core/assets/vendor/html5shiv/html5shiv.min.js', 'The html5shiv library from core should be excluded from loading.');
$this
->assertNoRaw('/core/misc/drupalSettingsLoader.js', 'The drupalSettings library from core should be excluded from loading.');
$this
->drupalGet('node');
$this
->assertRaw('/core/assets/vendor/html5shiv/html5shiv.min.js', 'The html5shiv library from core should be included in loading.');
$this
->assertRaw('/core/misc/drupalSettingsLoader.js', 'The drupalSettings library from core should be included in loading.');
}
}
Classes
Name |
Description |
AjaxPageStateTest |
Performs tests for the effects of the ajax_page_state query parameter. |