You are here

private function PanelizerWizardTest::assertBlockExistsInRegion 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.

1 call to PanelizerWizardTest::assertBlockExistsInRegion()
PanelizerWizardTest::testChangeLayouts in tests/src/FunctionalJavascript/PanelizerWizardTest.php
Tests switching between defined layouts in the Panelizer wizard.

File

tests/src/FunctionalJavascript/PanelizerWizardTest.php, line 92

Class

PanelizerWizardTest
Tests Lightning Layout's integration with Panelizer's wizard.

Namespace

Drupal\Tests\lightning_layout\FunctionalJavascript

Code

private function assertBlockExistsInRegion($block_label, $region) {
  $page = $this
    ->getSession()
    ->getPage();
  $rows = [];
  foreach ($page
    ->findAll('css', ".block-region-select option[value='{$region}'][selected]") as $element) {

    // Traverse upwards to the containing TR element.
    $rows[] = $element
      ->getParent()
      ->getParent()
      ->getParent()
      ->getParent();
  }

  /** @var \Behat\Mink\Element\NodeElement $row */
  foreach ($rows 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;
    }
  }
  $this
    ->fail("Expected block '{$block_label}' to be present in '{$region}' region.");
}