You are here

protected function ParagraphsContentModerationTest::getTableRowWithText in Paragraphs 8

Retrieve a table row containing specified text from a given element.

Parameters

\Behat\Mink\Element\Element $table: The table element.

string $search: The text to search for in the table row.

Return value

\Behat\Mink\Element\NodeElement The row element.

Throws

\Exception

2 calls to ParagraphsContentModerationTest::getTableRowWithText()
ParagraphsContentModerationTest::testModeratedContentNestedParagraphs in modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsContentModerationTest.php
Tests the moderated content that includes nested paragraphs.
ParagraphsContentModerationTest::testModeratedParagraphedContent in modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsContentModerationTest.php
Tests the moderated paragraphed content.

File

modules/paragraphs_library/tests/src/FunctionalJavascript/ParagraphsContentModerationTest.php, line 641

Class

ParagraphsContentModerationTest
Tests Paragraphs, Paragraphs Library and Content Moderation integration.

Namespace

Drupal\Tests\paragraphs_library\FunctionalJavascript

Code

protected function getTableRowWithText(Element $table, $search) {
  $rows = $table
    ->findAll('css', 'tr');
  if (empty($rows)) {
    throw new \Exception(sprintf('No rows found on the received table element.'));
  }
  foreach ($rows as $row) {
    if (strpos($row
      ->getText(), $search) !== FALSE) {
      return $row;
    }
  }
  throw new \Exception(sprintf('Failed to find a row containing "%s" on the received table.', $search));
}