mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Fixed screenshot_path usage
Was referencing outdated $this->context settings instead of parent context. Still a bit hacky to make assumptions on parent context, but its difficult to pass through arguments to subcontexts.
This commit is contained in:
parent
b0ede964c4
commit
7bb06f0fea
@ -109,8 +109,8 @@ Optional `ajax_steps` is used to match steps defined there so they can be "caugh
|
|||||||
[special AJAX handlers](http://blog.scur.pl/2012/06/ajax-callback-support-behat-mink/) that tweak the delays. You can either use a pipe delimited string or a list of substrings that match step definition.
|
[special AJAX handlers](http://blog.scur.pl/2012/06/ajax-callback-support-behat-mink/) that tweak the delays. You can either use a pipe delimited string or a list of substrings that match step definition.
|
||||||
* `ajax_timeout`: Milliseconds after which an Ajax request is regarded as timed out,
|
* `ajax_timeout`: Milliseconds after which an Ajax request is regarded as timed out,
|
||||||
and the script continues with its assertions to avoid a deadlock (Default: 5000).
|
and the script continues with its assertions to avoid a deadlock (Default: 5000).
|
||||||
* `screenshot_path`: Used to store screenshot of a last known state
|
* `screenshot_path`: Absolute path used to store screenshot of a last known state
|
||||||
of a failed step. It defaults to whatever is returned by PHP's `sys_get_temp_dir()`.
|
of a failed step.
|
||||||
Screenshot names within that directory consist of feature file filename and line
|
Screenshot names within that directory consist of feature file filename and line
|
||||||
number that failed.
|
number that failed.
|
||||||
|
|
||||||
@ -120,7 +120,8 @@ Example: behat.yml
|
|||||||
context:
|
context:
|
||||||
class: SilverStripe\MyModule\Test\Behaviour\FeatureContext
|
class: SilverStripe\MyModule\Test\Behaviour\FeatureContext
|
||||||
extensions:
|
extensions:
|
||||||
SilverStripe\BehatExtension\Extension: ~
|
SilverStripe\BehatExtension\Extension:
|
||||||
|
screenshot_path: %behat.paths.base%/artifacts/screenshots
|
||||||
SilverStripe\BehatExtension\MinkExtension:
|
SilverStripe\BehatExtension\MinkExtension:
|
||||||
# Adjust this to your local environment
|
# Adjust this to your local environment
|
||||||
base_url: http://localhost/
|
base_url: http://localhost/
|
||||||
|
@ -211,19 +211,16 @@ JS;
|
|||||||
$path = $this->getMainContext()->getScreenshotPath();
|
$path = $this->getMainContext()->getScreenshotPath();
|
||||||
if(!$path) return; // quit silently when path is not set
|
if(!$path) return; // quit silently when path is not set
|
||||||
|
|
||||||
|
\Filesystem::makeFolder($path);
|
||||||
$path = realpath($path);
|
$path = realpath($path);
|
||||||
if (!$path) {
|
|
||||||
\Filesystem::makeFolder($this->context['screenshot_path']);
|
|
||||||
$path = realpath($this->context['screenshot_path']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
file_put_contents('php://stderr', sprintf('"%s" is not valid directory and failed to create it' . PHP_EOL, $this->context['screenshot_path']));
|
file_put_contents('php://stderr', sprintf('"%s" is not valid directory and failed to create it' . PHP_EOL, $path));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($path) && !is_dir($path)) {
|
if (file_exists($path) && !is_dir($path)) {
|
||||||
file_put_contents('php://stderr', sprintf('"%s" is not valid directory' . PHP_EOL, $this->context['screenshot_path']));
|
file_put_contents('php://stderr', sprintf('"%s" is not valid directory' . PHP_EOL, $path));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (file_exists($path) && !is_writable($path)) {
|
if (file_exists($path) && !is_writable($path)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user