public function ToolbarAdminMenuTest::testSubtreesJsonRequest in Drupal 9
Same name and namespace in other branches
- 8 core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php \Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::testSubtreesJsonRequest()
Tests that the 'toolbar/subtrees/{hash}' is reachable and correct.
File
- core/
modules/ toolbar/ tests/ src/ Functional/ ToolbarAdminMenuTest.php, line 369
Class
- ToolbarAdminMenuTest
- Tests the caching of the admin menu subtree items.
Namespace
Drupal\Tests\toolbar\FunctionalCode
public function testSubtreesJsonRequest() {
$admin_user = $this->adminUser;
$this
->drupalLogin($admin_user);
// Request a new page to refresh the drupalSettings object.
$subtrees_hash = $this
->getSubtreesHash();
$this
->drupalGet('toolbar/subtrees/' . $subtrees_hash, [
'query' => [
MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax',
],
], [
'X-Requested-With: XMLHttpRequest',
]);
$ajax_result = json_decode($this
->getSession()
->getPage()
->getContent(), TRUE);
$this
->assertEquals('setToolbarSubtrees', $ajax_result[0]['command'], 'Subtrees response uses the correct command.');
$this
->assertEquals([
'system-admin_content',
'system-admin_structure',
'system-themes_page',
'system-modules_list',
'system-admin_config',
'entity-user-collection',
'front',
], array_keys($ajax_result[0]['subtrees']), 'Correct subtrees returned.');
}