public static function TestSubContext::clearPhpBehatNoticeLogs in Panopoly 8.2
Same name and namespace in other branches
- 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::clearPhpBehatNoticeLogs()
If we will flag PHP errors, clear all of them before we run a suite.
@BeforeSuite
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 145 - Provide Behat step-definitions for generic Panopoly tests.
Class
- TestSubContext
- Behat sub-context for Panopoly.
Code
public static function clearPhpBehatNoticeLogs() {
if (!empty(getenv('PANOPOLY_BEHAT_FLAG_PHP_NOTICES'))) {
\Drupal::database()
->delete('watchdog')
->condition('type', [
'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";
}
}
}
}