],
'#access' => FALSE,
],
];
// Start with a fresh copy of the base array, and try rendering the entire
// thing. We expect a single <ul> with appropriate links contained within
// it.
$render_array =
$base_array;
$html = \Drupal::
service('renderer'
)->
renderRoot($render_array);
$dom =
new \
DOMDocument();
$dom->
loadHTML($html);
$this->
assertEquals(1,
$dom->
getElementsByTagName('ul'
)->length, 'One "ul" tag found in the rendered HTML.'
);
$list_elements =
$dom->
getElementsByTagName('li'
);
$this->
assertEquals(3,
$list_elements->length, 'Three "li" tags found in the rendered HTML.'
);
$this->
assertEquals('Parent link original',
$list_elements->
item(0
)->nodeValue, 'First expected link found.'
);
$this->
assertEquals('First child link',
$list_elements->
item(1
)->nodeValue, 'Second expected link found.'
);
$this->
assertEquals('Second child link',
$list_elements->
item(2
)->nodeValue, 'Third expected link found.'
);
$this->
assertStringNotContainsString('Parent link copy',
$html, '"Parent link copy" link not found.'
);
$this->
assertStringNotContainsString('Third child link',
$html, '"Third child link" link not found.'
);
// Now render 'first_child', followed by the rest of the links, and make