Commit 0feb1b69 authored by alexpott's avatar alexpott

Issue #2534830 by Wim Leers: Toolbar subtrees not working

parent 7fb23ea2
......@@ -22,7 +22,7 @@ class ToolbarController extends ControllerBase {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function subtreesJsonp() {
$subtrees = toolbar_get_rendered_subtrees();
list($subtrees, $cacheability) = toolbar_get_rendered_subtrees();
$response = new JsonResponse($subtrees);
$response->setCallback('Drupal.toolbar.setSubtrees.resolve');
......
......@@ -7,6 +7,7 @@
namespace Drupal\toolbar\Tests;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage;
......@@ -331,7 +332,7 @@ function testLocaleTranslationSubtreesHashCacheClear() {
}
/**
* Tests that the 'toolbar/subtrees/{hash}' is reachable.
* Tests that the 'toolbar/subtrees/{hash}' is reachable and correct.
*/
function testSubtreesJsonRequest() {
$admin_user = $this->adminUser;
......@@ -341,6 +342,12 @@ function testSubtreesJsonRequest() {
$this->drupalGetJSON('toolbar/subtrees/' . $subtrees_hash);
$this->assertResponse('200');
$json_callback_start = substr($this->getRawContent(), 0, 39);
$json_callback_end = substr($this->getRawContent(), -2, 2);
$json = substr($this->getRawContent(), 39, strlen($this->getRawContent()) - 41);
$this->assertTrue($json_callback_start === '/**/Drupal.toolbar.setSubtrees.resolve(' && $json_callback_end === ');', 'Subtrees response is wrapped in callback.');
$subtrees = Json::decode($json);
$this->assertEqual(array_keys($subtrees), ['system-admin_content', 'system-admin_structure', 'system-themes_page', 'system-modules_list', 'system-admin_config', 'entity-user-collection', 'front'], 'Correct subtrees JSON returned.');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment