protected function PanelizerContext::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 PanelizerContext::getBlockRow()
- PanelizerContext::assertBlock in tests/
contexts/ PanelizerContext.behat.inc - Asserts that a block is present in a specific region of a Panelizer layout.
File
- tests/
contexts/ PanelizerContext.behat.inc, line 100
Class
Namespace
Acquia\LightningExtension\ContextCode
protected 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;
}
}
}