You are here

public function ModerationContext::compareRevisions in Lightning Workflow 8.3

Compares two revisions of a node.

@When I compare the :a and :b revisions

Parameters

string $a: The one-based index of a revision to compare. 1st is oldest.

string $b: The one-based index of a revision to compare. 1st is oldest.

File

tests/contexts/ModerationContext.behat.inc, line 158

Class

ModerationContext
Contains miscellaneous step definitions for testing moderation UIs.

Namespace

Acquia\LightningExtension\Context

Code

public function compareRevisions($a, $b) {
  $page = $this
    ->getSession()
    ->getPage();
  $re = '/^[0-9]+(st|nd|rd|th)$/i';
  if (preg_match($re, $a)) {
    $a = substr($a, 0, -2);
  }
  if (preg_match($re, $b)) {
    $b = substr($b, 0, -2);
  }
  $a = (int) $a - 1;
  $b = (int) $b - 1;
  $page
    ->clickLink('Revisions');

  /** @var \Behat\Mink\Element\NodeElement[] $rows */
  $rows = $page
    ->findAll('css', '.diff-revisions tbody tr');
  $rows = array_reverse($rows);
  $a = $rows[$a]
    ->findField('radios_left')
    ->getValue();
  $b = $rows[$b]
    ->findField('radios_right')
    ->getValue();
  $page
    ->selectFieldOption('radios_left', $a);
  $page
    ->selectFieldOption('radios_right', $b);
  $page
    ->pressButton('Compare');
}