$expected_links .= '<li><span class="a/class">' . Html::
escape('Plain "text"'
) . '</span></li>';
$expected_links .= '<li><span class="unescaped">' . Html::
escape('potentially unsafe text that <should> be escaped'
) . '</span></li>';
$expected_links .= '<li><a href="' . Url::
fromRoute('<front>'
)->
toString() . '">' . Html::
escape('Front page'
) . '</a></li>';
$expected_links .= '<li><a href="' . \Drupal::
urlGenerator()->
generate('router_test.1'
) . '">' . Html::
escape('Test route'
) . '</a></li>';
$query =
['key' => 'value'
];
$expected_links .= '<li><a href="' . \Drupal::
urlGenerator()->
generate('router_test.1',
$query) . '">' . Html::
escape('Query test route'
) . '</a></li>';
$expected_links .= '</ul>';
$expected =
$expected_heading .
$expected_links;
$this->
assertThemeOutput('links',
$variables,
$expected);
// Verify the data- attributes for setting the "active" class on links.
\Drupal::
currentUser()->
setAccount(new UserSession(['uid' => 1
]));
$variables['set_active_class'
] = TRUE;
$expected_links = '';
$expected_links .= '<ul id="somelinks">';
$expected_links .= '<li><a href="' . Url::
fromUri('base:a/link'
)->
toString() . '">' . Html::
escape('A <link>'
) . '</a></li>';
$expected_links .= '<li><span class="a/class">' . Html::
escape('Plain "text"'
) . '</span></li>';
$expected_links .= '<li><span class="unescaped">' . Html::
escape('potentially unsafe text that <should> be escaped'
) . '</span></li>';
$expected_links .= '<li data-drupal-link-system-path="<front>"><a href="' . Url::
fromRoute('<front>'
)->
toString() . '" data-drupal-link-system-path="<front>">' . Html::
escape('Front page'
) . '</a></li>';
$expected_links .= '<li data-drupal-link-system-path="router_test/test1"><a href="' . \Drupal::
urlGenerator()->
generate('router_test.1'
) . '" data-drupal-link-system-path="router_test/test1">' . Html::
escape('Test route'
) . '</a></li>';
$query =
['key' => 'value'
];
$encoded_query = Html::
escape(Json::
encode($query));
$expected_links .= '<li 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">' . Html::
escape('Query test route'
) . '</a></li>';