You are here

public function EntityContext::visitCurrentRevision in Lightning Core 8.5

Same name and namespace in other branches
  1. 8 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::visitCurrentRevision()
  2. 8.2 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::visitCurrentRevision()
  3. 8.3 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::visitCurrentRevision()
  4. 8.4 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::visitCurrentRevision()

Visits the current revision of a node.

@When I visit the current revision

File

tests/contexts/EntityContext.behat.inc, line 286

Class

EntityContext
Contains miscellaneous step definitions for working with Drupal entities.

Namespace

Acquia\LightningExtension\Context

Code

public function visitCurrentRevision() {
  $this
    ->assertSession()
    ->elementExists('named', [
    'link',
    'Revisions',
  ])
    ->click();
  $session = $this
    ->getSession();

  // The revision table's selector may vary depending on whether or not Diff
  // is installed, so we need to use a pretty general selector.
  $rows = $session
    ->getPage()
    ->findAll('css', 'main table > tbody tr');

  /** @var \Behat\Mink\Element\NodeElement $row */
  foreach ($rows as $row) {
    if ($row
      ->find('css', 'td:last-child')
      ->getText() == 'Current revision') {
      return $row
        ->find('css', 'td:first-child a')
        ->click();
    }
  }

  // WTF? None of the rows were the current revision.
  throw new ExpectationException('Current revision not found.', $session
    ->getDriver());
}