function ViewsViewFieldStatusTest::renderStatusFieldByMarker
Renders the status field of every row of a view, keyed by marker class.
Parameters
\Drupal\views\ViewExecutable $view: An executed view with a field with the ID 'status'.
Return value
array The text inside the marker, keyed by the class attribute of the marker element. Output that is not wrapped in a marker is keyed by an empty string. Sorted by key, because the order of the rows of a view is not relevant for this test.
4 calls to ViewsViewFieldStatusTest::renderStatusFieldByMarker()
- ViewsViewFieldStatusTest::testNodePublicationState in core/
themes/ default_admin/ tests/ src/ Kernel/ ViewsViewFieldStatusTest.php - Tests the marker of published and unpublished nodes.
- ViewsViewFieldStatusTest::testNodeTranslationPublicationState in core/
themes/ default_admin/ tests/ src/ Kernel/ ViewsViewFieldStatusTest.php - Tests that the marker of a node row follows the row translation.
- ViewsViewFieldStatusTest::testTermPublicationState in core/
themes/ default_admin/ tests/ src/ Kernel/ ViewsViewFieldStatusTest.php - Tests the marker of a publishable entity type other than the node type.
- ViewsViewFieldStatusTest::testTermTranslationPublicationState in core/
themes/ default_admin/ tests/ src/ Kernel/ ViewsViewFieldStatusTest.php - Tests that the marker of a term row follows the row translation.
File
-
core/
themes/ default_admin/ tests/ src/ Kernel/ ViewsViewFieldStatusTest.php, line 369
Class
- ViewsViewFieldStatusTest
- Tests the publication status marker of views status fields.
Namespace
Drupal\Tests\default_admin\KernelCode
protected function renderStatusFieldByMarker(ViewExecutable $view) : array {
$rendered = [];
foreach ($view->result as $row) {
$output = $this->renderStatusField($view, $row);
if (preg_match('#^<span class="(marker[^"]*)">(.*)</span>$#s', $output, $matches) === 1) {
$rendered[$matches[1]] = $matches[2];
}
else {
$rendered[''] = $output;
}
}
ksort($rendered);
return $rendered;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.