You are here

public static function TestSubContext::clearPhpBehatNoticeLogs in Panopoly 7

Same name and namespace in other branches
  1. 8.2 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::clearPhpBehatNoticeLogs()

@BeforeSuite

If we will flag PHP errors, clear all of them before we run a suite.

File

modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc, line 141
Provide Behat step-definitions for generic Panopoly tests.

Class

TestSubContext

Code

public static function clearPhpBehatNoticeLogs() {
  if (!empty(getenv('PANOPOLY_BEHAT_FLAG_PHP_NOTICES'))) {
    db_delete('watchdog')
      ->condition('type', array(
      'php',
      'behat',
    ), 'IN')
      ->execute();
    $local_file_path = getenv('PANOPOLY_BEHAT_SCREENSHOT_PATH');
    if (empty($local_file_path)) {
      print "Environment variable PANOPOLY_BEHAT_SCREENSHOT_PATH is not set, unable to save errors\n";
    }
    elseif (!is_dir($local_file_path)) {
      print "Directory {$local_file_path} does not exist, unable to save errors\n";
    }
    else {
      $file_location = "{$local_file_path}/behat-php-errors.txt";
      if (@file_put_contents($file_location, "Scenario|Time|Message\r\n") !== FALSE) {
        print "PHP errors will be saved to {$file_location}\n";
      }
      else {
        print "Unable to save errors\n";
      }
    }
  }
}