You are here

public function SocialMinkContext::takeScreenShotAfterFailedStep in Open Social 8

Same name and namespace in other branches
  1. 8.2 tests/behat/features/bootstrap/SocialMinkContext.php \SocialMinkContext::takeScreenShotAfterFailedStep()

@AfterStep

File

tests/behat/features/bootstrap/SocialMinkContext.php, line 65

Class

SocialMinkContext
Defines application features from the specific context.

Code

public function takeScreenShotAfterFailedStep(AfterStepScope $scope) {
  if (99 === $scope
    ->getTestResult()
    ->getResultCode()) {
    $driver = $this
      ->getSession()
      ->getDriver();
    if (!$driver instanceof Selenium2Driver) {
      return;
    }
    $feature = $scope
      ->getFeature();
    $title = $feature
      ->getTitle();
    $filename = date("Ymd-H_i_s");
    if (!empty($title)) {
      $filename .= '-' . str_replace(' ', '-', strtolower($title));
    }
    $filename .= '-error';
    $this
      ->iMakeAScreenshotWithFileName($filename);
  }
}