private function PanelizerTest::getBlockRow in Lightning Layout 8
Returns the table row for a specific block in a specific region.
Parameters
string $block_label: The label of the block to locate.
string $region: The machine name of the region in which the block is expected to be.
Return value
\Behat\Mink\Element\NodeElement|null The row element, or null if one was not found.
1 call to PanelizerTest::getBlockRow()
- PanelizerTest::testCreateLayout in tests/
src/ Functional/ PanelizerTest.php - Tests creating a Panelizer layout in the wizard.
File
- tests/
src/ Functional/ PanelizerTest.php, line 103
Class
- PanelizerTest
- Tests basic integration with Panelizer.
Namespace
Drupal\Tests\lightning_layout\FunctionalCode
private function getBlockRow($block_label, $region) {
$page = $this
->getSession()
->getPage();
// array_map() callback. Traverses from a region select list to the table
// row that contains it.
$row_map = function (NodeElement $select) {
// $select->containing DIV->table cell->table row.
return $select
->getParent()
->getParent()
->getParent();
};
$elements = array_filter($page
->findAll('css', 'table#blocks tr > td > div > select.block-region-select'), function (NodeElement $element) use ($region) {
return $element
->getValue() == $region;
});
/** @var \Behat\Mink\Element\NodeElement $row */
foreach (array_map($row_map, $elements) as $row) {
// The first cell is the one with the label; find() will return the first
// matched element, which should be the first cell.
$row_label = $row
->find('css', 'td')
->getText();
if (trim($row_label) == $block_label) {
return $row;
}
}
}