From 93beccc5715e4cb3e645f560e605b59b9be8b880 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 13 Aug 2014 14:01:36 -0700 Subject: [PATCH] Issue #2217755 by Alumei, Les Lim, er.pushpinderrana, martin107, Daniel Norton | alexpott: Fixed template_preprocess_links uses a non existent class JSON. --- core/includes/theme.inc | 1 + .../system/src/Tests/Theme/FunctionsTest.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f7acb39cbda9..7187666e0eb7 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -8,6 +8,7 @@ * customized by user themes. */ +use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\String; use Drupal\Component\Utility\UrlHelper; diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index 577e07595984..b0fe3050980e 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -7,11 +7,10 @@ namespace Drupal\system\Tests\Theme; +use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\String; use Drupal\Core\Session\UserSession; use Drupal\simpletest\WebTestBase; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Component\HttpFoundation\Request; /** * Tests for common theme functions. @@ -206,6 +205,14 @@ function testLinks() { 'route_name' => 'router_test.1', 'route_parameters' => array(), ), + 'query-test' => array( + 'title' => 'Query test route', + 'route_name' => 'router_test.1', + 'route_parameters' => array(), + 'query' => array( + 'key' => 'value', + ) + ), ); $expected_links = ''; @@ -214,6 +221,8 @@ function testLinks() { $expected_links .= '<li class="plain-text">' . String::checkPlain('Plain "text"') . '</li>'; $expected_links .= '<li class="front-page"><a href="' . url('<front>') . '">' . String::checkPlain('Front page') . '</a></li>'; $expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . String::checkPlain('Test route') . '</a></li>'; + $query = array('key' => 'value'); + $expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . String::checkPlain('Query test route') . '</a></li>'; $expected_links .= '</ul>'; // Verify that passing a string as heading works. @@ -250,6 +259,8 @@ function testLinks() { $expected_links .= '<li class="plain-text"><span class="a/class">' . String::checkPlain('Plain "text"') . '</span></li>'; $expected_links .= '<li class="front-page"><a href="' . url('<front>') . '">' . String::checkPlain('Front page') . '</a></li>'; $expected_links .= '<li class="router-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '">' . String::checkPlain('Test route') . '</a></li>'; + $query = array('key' => 'value'); + $expected_links .= '<li class="query-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '">' . String::checkPlain('Query test route') . '</a></li>'; $expected_links .= '</ul>'; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); @@ -263,6 +274,9 @@ function testLinks() { $expected_links .= '<li class="plain-text"><span class="a/class">' . String::checkPlain('Plain "text"') . '</span></li>'; $expected_links .= '<li class="front-page" data-drupal-link-system-path="<front>"><a href="' . url('<front>') . '" data-drupal-link-system-path="<front>">' . String::checkPlain('Front page') . '</a></li>'; $expected_links .= '<li class="router-test" data-drupal-link-system-path="router_test/test1"><a href="' . \Drupal::urlGenerator()->generate('router_test.1') . '" data-drupal-link-system-path="router_test/test1">' . String::checkPlain('Test route') . '</a></li>'; + $query = array('key' => 'value'); + $encoded_query = String::checkPlain(Json::encode($query)); + $expected_links .= '<li class="query-test" data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '" data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1">' . String::checkPlain('Query test route') . '</a></li>'; $expected_links .= '</ul>'; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); -- GitLab