diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f7acb39cbda91b3dec087a3b6d09db272a60f58a..7187666e0eb7a4ce1e79394eed69ba7af9ee2379 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 577e075959841485854d12b93bb38a2536184398..b0fe3050980ec9e9766ec0f3863c0bfc925f8388 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 .= '
  • ' . String::checkPlain('Plain "text"') . '
  • '; $expected_links .= '
  • ' . String::checkPlain('Front page') . '
  • '; $expected_links .= '
  • ' . String::checkPlain('Test route') . '
  • '; + $query = array('key' => 'value'); + $expected_links .= '
  • ' . String::checkPlain('Query test route') . '
  • '; $expected_links .= ''; // Verify that passing a string as heading works. @@ -250,6 +259,8 @@ function testLinks() { $expected_links .= '
  • ' . String::checkPlain('Plain "text"') . '
  • '; $expected_links .= '
  • ' . String::checkPlain('Front page') . '
  • '; $expected_links .= '
  • ' . String::checkPlain('Test route') . '
  • '; + $query = array('key' => 'value'); + $expected_links .= '
  • ' . String::checkPlain('Query test route') . '
  • '; $expected_links .= ''; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); @@ -263,6 +274,9 @@ function testLinks() { $expected_links .= '
  • ' . String::checkPlain('Plain "text"') . '
  • '; $expected_links .= '
  • ' . String::checkPlain('Front page') . '
  • '; $expected_links .= '
  • ' . String::checkPlain('Test route') . '
  • '; + $query = array('key' => 'value'); + $encoded_query = String::checkPlain(Json::encode($query)); + $expected_links .= '
  • ' . String::checkPlain('Query test route') . '
  • '; $expected_links .= ''; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected);