function SelectionTest::testAnchorTagStripping
Same name in other branches
- 9 core/modules/field/tests/src/Kernel/EntityReference/Views/SelectionTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\SelectionTest::testAnchorTagStripping()
- 10 core/modules/field/tests/src/Kernel/EntityReference/Views/SelectionTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\SelectionTest::testAnchorTagStripping()
- 11.x core/modules/field/tests/src/Kernel/EntityReference/Views/SelectionTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\SelectionTest::testAnchorTagStripping()
Tests the anchor tag stripping.
Unstripped results based on the data above will result in output like so: ...<a href="/node/1" hreflang="en">Test first node</a>... ...<a href="/node/2" hreflang="en">Test second node</a>... ...<a href="/node/3" hreflang="en">Test third node</a>... If we expect our output to not have the <a> tags, and this matches what's produced by the tag-stripping method, we'll know that it's working.
File
-
core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ Views/ SelectionTest.php, line 132
Class
- SelectionTest
- Tests entity reference selection handler.
Namespace
Drupal\Tests\field\Kernel\EntityReference\ViewsCode
public function testAnchorTagStripping() {
$filtered_rendered_results_formatted = [];
foreach ($this->selectionHandler
->getReferenceableEntities() as $subresults) {
$filtered_rendered_results_formatted += $subresults;
}
// Note the missing <a> tags.
$expected = [
1 => '<span class="views-field views-field-title"><span class="field-content">' . Html::escape($this->nodes[1]
->label()) . '</span></span>',
2 => '<span class="views-field views-field-title"><span class="field-content">' . Html::escape($this->nodes[2]
->label()) . '</span></span>',
3 => '<span class="views-field views-field-title"><span class="field-content">' . Html::escape($this->nodes[3]
->label()) . '</span></span>',
];
$this->assertEqual($filtered_rendered_results_formatted, $expected, 'Anchor tag stripping has failed.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.