Skip to content

Commit 415a475

Browse files
Nils LangnerNils Langner
authored andcommitted
Updated VisualCeption; added getReferenceImageDir()
1 parent 73ddf20 commit 415a475

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

module/VisualCeption.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class VisualCeption extends \Codeception\Module
2020
private $referenceImageDir;
2121

2222
private $maximumDeviation = 0;
23-
private $saveCurrentImageIfFailure = false;
2423

2524
private $webDriver = null;
2625
private $webDriverModule = null;
@@ -60,6 +59,11 @@ public function _before(\Codeception\TestCase $test)
6059
$this->test = $test;
6160
}
6261

62+
public function getReferenceImageDir()
63+
{
64+
return $this->referenceImageDir;
65+
}
66+
6367
/**
6468
* Compare the reference image with a current screenshot, identified by their indentifier name
6569
* and their element ID.
@@ -83,11 +87,6 @@ public function seeVisualChanges($identifier, $elementID = null, $excludeElement
8387
$compareScreenshotPath = $this->getDeviationScreenshotPath($identifier);
8488
$deviationResult["deviationImage"]->writeImage($compareScreenshotPath);
8589

86-
if ($this->saveCurrentImageIfFailure === true) {
87-
$saveCurrentImagePath = $this->getDeviationScreenshotPath($identifier, 'current');
88-
$deviationResult['currentImage']->writeImage($saveCurrentImagePath);
89-
}
90-
9190
throw new ImageDeviationException("The deviation of the taken screenshot is too low (" . $deviationResult["deviation"] . "%).\nSee $compareScreenshotPath for a deviation screenshot.",
9291
$this->getExpectedScreenshotPath($identifier),
9392
$this->getScreenshotPath($identifier),
@@ -119,11 +118,6 @@ public function dontSeeVisualChanges($identifier, $elementID = null, $excludeEle
119118
$compareScreenshotPath = $this->getDeviationScreenshotPath($identifier);
120119
$deviationResult["deviationImage"]->writeImage($compareScreenshotPath);
121120

122-
if ($this->saveCurrentImageIfFailure === true) {
123-
$saveCurrentImagePath = $this->getDeviationScreenshotPath($identifier, 'current.');
124-
$deviationResult['currentImage']->writeImage($saveCurrentImagePath);
125-
}
126-
127121
throw new ImageDeviationException("The deviation of the taken screenshot is too hight (" . $deviationResult["deviation"] . "%).\nSee $compareScreenshotPath for a deviation screenshot.",
128122
$this->getExpectedScreenshotPath($identifier),
129123
$this->getScreenshotPath($identifier),
@@ -177,8 +171,6 @@ private function getDeviation($identifier, $elementID, array $excludeElements =
177171

178172
$compareResult = $this->compare($identifier);
179173

180-
unlink($this->getScreenshotPath($identifier));
181-
182174
$deviation = round($compareResult[1] * 100, 2);
183175

184176
$this->debug("The deviation between the images is ". $deviation . " percent");
@@ -366,7 +358,7 @@ private function resetHideElementsForScreenshot(array $excludeElements)
366358
private function getDeviationScreenshotPath ($identifier, $alternativePrefix = '')
367359
{
368360
$debugDir = \Codeception\Configuration::logDir() . 'debug/';
369-
$prefix = ( $alternativePrefix === '') ? 'compare.' : $alternativePrefix;
361+
$prefix = ( $alternativePrefix === '') ? 'compare' : $alternativePrefix;
370362
return $debugDir . $prefix . $this->getScreenshotName($identifier);
371363
}
372364

@@ -428,4 +420,4 @@ private function compareImages($image1, $image2)
428420
}
429421
return $result;
430422
}
431-
}
423+
}

0 commit comments

Comments
 (0)