function ContextualUnitTest::testThemePlaceholder
Tests the placeholder of contextual links in a specific theme.
@legacy-covers \Drupal\contextual\Element\ContextualLinksPlaceholder::preRenderPlaceholder
Attributes
#[DataProvider('contextualLinksDataProvider')]
Parameters
array $links: The #contextual_links property value array.
string $id: The serialized representation of the passed links.
string $theme: The name of the theme the placeholder should pass to the controller.
File
-
core/
modules/ contextual/ tests/ src/ Kernel/ ContextualUnitTest.php, line 149
Class
- ContextualUnitTest
- Tests edge cases for converting between contextual links and IDs.
Namespace
Drupal\Tests\contextual\KernelCode
public function testThemePlaceholder(array $links, string $id, string $theme) : void {
\Drupal::service('theme_installer')->install([
$theme,
]);
\Drupal::configFactory()->getEditable('system.theme')
->set('default', $theme)
->save();
$element = [
'#type' => 'contextual_links_placeholder',
'#id' => $id,
'#pre_render' => [
[
'Drupal\\contextual\\Element\\ContextualLinksPlaceholder',
'preRenderPlaceholder',
],
],
'#defaults_loaded' => TRUE,
];
$output = ContextualLinksPlaceholder::preRenderPlaceholder($element);
$this->assertEquals($theme, $output['#attached']['drupalSettings']['contextual']['theme']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.