You are here

class DebugContext in Lightning Core 8.2

Same name and namespace in other branches
  1. 8.5 tests/contexts/DebugContext.behat.inc \Acquia\LightningExtension\Context\DebugContext
  2. 8 tests/contexts/DebugContext.behat.inc \Acquia\LightningExtension\Context\DebugContext
  3. 8.3 tests/contexts/DebugContext.behat.inc \Acquia\LightningExtension\Context\DebugContext
  4. 8.4 tests/contexts/DebugContext.behat.inc \Acquia\LightningExtension\Context\DebugContext

Contains step definitions to assist with debugging tests.

@internal This class is part of Lightning's internal testing code. It is not an API and should not be extended. This class will be marked final, and all protected members will be made private, in Lightning Core 3.x.

Hierarchy

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

Expanded class hierarchy of DebugContext

File

tests/contexts/DebugContext.behat.inc, line 15

Namespace

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

  /**
   * The number of screenshots that have been taken during the scenario.
   *
   * @var int
   */
  private $screenshotCount = 0;

  /**
   * Waits a while, for debugging.
   *
   * @param int $seconds
   *   How long to wait.
   *
   * @When I wait :seconds second(s)
   */
  public function wait($seconds) {
    sleep($seconds);
  }

  /**
   * Dumps the current page HTML.
   *
   * @When I dump the HTML
   */
  public function dumpHTML() {
    print_r($this
      ->getSession()
      ->getPage()
      ->getContent());
  }

  /**
   * Takes a screenshot.
   *
   * @param string $filename
   *   (optional) Ignored. The filename is based on a counter and prefixed with
   *   the name of the Mink browser.
   * @param null $filepath
   *   (optional) Ignored. The screenshot is saved in the directory above the
   *   Drupal root.
   *
   * @When I take a screenshot
   */
  public function saveScreenshot($filename = NULL, $filepath = NULL) {
    $filename = sprintf('%s_%d.png', $this
      ->getMinkParameter('browser_name'), ++$this->screenshotCount);
    $filepath = \Drupal::root() . '/../';
    parent::saveScreenshot($filename, $filepath);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DebugContext::$screenshotCount private property The number of screenshots that have been taken during the scenario.
DebugContext::dumpHTML public function Dumps the current page HTML.
DebugContext::saveScreenshot public function Takes a screenshot.
DebugContext::wait public function Waits a while, for debugging.