Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG tweak screenshot take logic to create directory

take screenshot logic now creates directory if provided and not existing in the filesystem
  • Loading branch information...
commit e1654029dc9a34480e181c2df7c3415ce8b5bc32 1 parent 955f951
@michalochman authored
View
2  behat.yml
@@ -4,7 +4,7 @@ default:
parameters:
admin_url: /admin/
login_url: /Security/login
- screenshot_path: features/screenshots/
+ screenshot_path: %behat.paths.features%/screenshots/
extensions:
features/extensions/SilverStripeExtension/init.php:
# Behat\SilverStripeExtension\Extension:
View
17 features/bootstrap/SilverStripe/Test/Behaviour/BasicContext.php
@@ -192,18 +192,29 @@ public function takeScreenshot(StepEvent $event) {
$parent = $event->getLogicalParent();
$feature = $parent->getFeature();
$step = $event->getStep();
+ $screenshot_path = null;
if (isset($this->context['screenshot_path'])) {
$screenshot_path = realpath($this->context['screenshot_path']);
- } else {
+ if (!$screenshot_path) {
+ \Filesystem::makeFolder($this->context['screenshot_path']);
+ $screenshot_path = realpath($this->context['screenshot_path']);
+ }
+ }
+ if (!$screenshot_path) {
$screenshot_path = realpath(sys_get_temp_dir());
}
- if (!is_dir($screenshot_path)) {
+ if (!file_exists($screenshot_path)) {
+ file_put_contents('php://stderr', sprintf('"%s" is not valid directory and failed to create it' . PHP_EOL, $this->context['screenshot_path']));
+ return;
+ }
+
+ if (file_exists($screenshot_path) && !is_dir($screenshot_path)) {
file_put_contents('php://stderr', sprintf('"%s" is not valid directory' . PHP_EOL, $this->context['screenshot_path']));
return;
}
- if (!is_writable($screenshot_path)) {
+ if (file_exists($screenshot_path) && !is_writable($screenshot_path)) {
file_put_contents('php://stderr', sprintf('"%s" directory is not writable' . PHP_EOL, $screenshot_path));
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.