You are here

final class DebugContext in Lightning Core 8.5

Same name and namespace in other branches
  1. 8 tests/contexts/DebugContext.behat.inc \Acquia\LightningExtension\Context\DebugContext
  2. 8.2 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 is an internal part of Lightning Core's testing system and may be changed or removed at any time without warning. It should not be extended, instantiated, or used in any way by external code! If you need to use this functionality, you should copy the relevant code into your own project.

Hierarchy

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

Expanded class hierarchy of DebugContext

File

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

Namespace

Acquia\LightningExtension\Context
View source
final 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 mixed $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.