@@ -237,4 +237,99 @@ public function testSystemCompactLink(): void {
$this->assertNotEmpty($result,'"'.$element['name'].'" is rendered correctly.');
}
/**
* Tests system #type 'link'.
*/
publicfunctiontestLink():void{
$elements=[
[
'name'=>"#type 'link' simple anchor tag",
'value'=>[
'#type'=>'link',
'#title'=>'title',
'#url'=>Url::fromUri('https://www.drupal.org'),
],
'expected'=>'//a[@href="https://www.drupal.org" and text()="title"]',
],
[
'name'=>"#type 'link' anchor tag with extra classes in ['#attributes']",
'value'=>[
'#type'=>'link',
'#title'=>'title',
'#url'=>Url::fromUri('https://www.drupal.org'),
'#attributes'=>[
'class'=>['attributes-class'],
],
'#options'=>[],
],
'expected'=>'//a[@href="https://www.drupal.org" and @class="attributes-class" and text()="title"]',
],
[
'name'=>"#type 'link' anchor tag with extra classes in ['#options']['attributes']",
'value'=>[
'#type'=>'link',
'#title'=>'title',
'#url'=>Url::fromUri('https://www.drupal.org'),
'#attributes'=>[],
'#options'=>[
'attributes'=>[
'class'=>['options-attributes-class'],
],
],
],
'expected'=>'//a[@href="https://www.drupal.org" and @class="options-attributes-class" and text()="title"]',
],
[
'name'=>"#type 'link' anchor tag with extra classes in both ['#attributes'] and ['#options']['attributes']",
'value'=>[
'#type'=>'link',
'#title'=>'title',
'#url'=>Url::fromUri('https://www.drupal.org'),
'#attributes'=>[
'class'=>['attributes-class'],
],
'#options'=>[
'attributes'=>[
'class'=>['options-attributes-class'],
],
],
],
'expected'=>'//a[@href="https://www.drupal.org" and @class="options-attributes-class attributes-class" and text()="title"]',
],
[
'name'=>"#type 'link' anchor tag with extra classes in both ['#attributes'] and ['#options']['attributes'] as strings",
'value'=>[
'#type'=>'link',
'#title'=>'title',
'#url'=>Url::fromUri('https://www.drupal.org'),
'#attributes'=>[
'class'=>'attributes-class',
],
'#options'=>[
'attributes'=>[
'class'=>'options-attributes-class',
],
],
],
'expected'=>'//a[@href="https://www.drupal.org" and contains(@class,"options-attributes-class") and contains(@class,"attributes-class") and text()="title"]',
],
[
'name'=>"#type 'link' anchor tag with extra classes in Url object ['#options']['attributes'] which are ignored",