You are here

class DiffContext in Lightning Workflow 8

Same name and namespace in other branches
  1. 8.2 tests/contexts/DiffContext.behat.inc \Acquia\LightningExtension\Context\DiffContext

Contains step definitions for interacting with the Diff module.

Hierarchy

  • class \Acquia\LightningExtension\Context\DiffContext extends \Drupal\DrupalExtension\Context\DrupalSubContextBase

Expanded class hierarchy of DiffContext

File

tests/contexts/DiffContext.behat.inc, line 11

Namespace

Acquia\LightningExtension\Context
View source
class DiffContext extends DrupalSubContextBase {

  /**
   * Compares two revisions of a node.
   *
   * @param string $a
   *   The one-based index of a revision to compare. 1st is oldest.
   * @param string $b
   *   The one-based index of a revision to compare. 1st is oldest.
   *
   * @When I compare the :a and :b revisions
   */
  public function compareRevisions($a, $b) {
    $assert = $this
      ->assertSession();

    /** @var MinkContext $context */
    $context = $this
      ->getContext(MinkContext::class);
    $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;
    $assert
      ->elementExists('named', [
      'link',
      'Revisions',
    ])
      ->click();

    /** @var \Behat\Mink\Element\NodeElement[] $rows */
    $rows = $this
      ->getSession()
      ->getPage()
      ->findAll('css', '.diff-revisions tbody tr');
    $rows = array_reverse($rows);
    $a = $rows[$a]
      ->findField('radios_left')
      ->getValue();
    $b = $rows[$b]
      ->findField('radios_right')
      ->getValue();
    $context
      ->selectOption('radios_left', $a);
    $context
      ->selectOption('radios_right', $b);
    $assert
      ->elementExists('named', [
      'button',
      'Compare',
    ])
      ->press();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DiffContext::compareRevisions public function Compares two revisions of a node.