Skip to content

Commit 34edc84

Browse files
committed
removed zrazy characters and updated screenshot naming path
1 parent 29fab87 commit 34edc84

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/Classes/Feature.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getScreenshotFolder()
108108
*/
109109
public function setScreenshotFolder($featureName)
110110
{
111-
$this->screenshotFolder = str_replace(' ','', $featureName);
111+
$this->screenshotFolder = $featureName;
112112
}
113113

114114
/**

src/Classes/Scenario.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getScreenshotName()
5454

5555
public function setScreenshotName($scenarioName)
5656
{
57-
$this->screenshotName = str_replace(' ','', $scenarioName) . '.png';
57+
$this->screenshotName = str_replace(' ','', $scenarioName);
5858
}
5959

6060
/**

src/Formatter/BehatFormatter.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ public function onBeforeFeatureTested(BeforeFeatureTested $event)
588588
$feature->setDescription($event->getFeature()->getDescription());
589589
$feature->setTags($event->getFeature()->getTags());
590590
$feature->setFile($event->getFeature()->getFile());
591-
$feature->setScreenshotFolder($event->getSuite()->getName().'/'.$event->getFeature()->getTitle());
591+
$feature->setScreenshotFolder(strtolower(preg_replace('/[^a-z]/i','',$event->getSuite()->getName()).'/'.preg_replace('/[^a-z]/i','',$event->getFeature()->getTitle())));
592592
$this->currentFeature = $feature;
593593

594594
$print = $this->renderer->renderBeforeFeature($this);
@@ -744,17 +744,17 @@ public function onAfterStepTested(AfterStepTested $event)
744744
}
745745
}
746746
}
747+
}
748+
749+
750+
$stepName = strtolower(preg_replace('/[^a-z]/i','',$event->getStep()->getText()));
751+
$relativeScreenshotPath = 'screenshots/' . $this->getCurrentFeature()->getScreenshotFolder() . '/' . strtolower($this->getCurrentScenario()->getScreenshotName()) . '/' . $stepName . '.png';
752+
$fullScreenshotPath = $this->getOutputPrinter()->getOutputPath() . '/' . $relativeScreenshotPath;
753+
754+
if (file_exists($fullScreenshotPath)) {
755+
$step->setScreenshot($relativeScreenshotPath);
747756
}
748-
if(($step->getResultCode() == "99") || ($step->getResult()->isPassed() && $step->getKeyword() === "Then")){
749-
$scenarioLine = empty($this->currentExampleLines) ? $this->currentScenario->getLine() : $this->currentExampleLines[$this->currentExampleCount++];
750-
$screenshot = $event->getSuite()->getName().".".basename($event->getFeature()->getFile()).".$scenarioLine.".$event->getStep()->getLine().".png";
751-
$screenshot = str_replace('.feature', '', $screenshot);
752-
753-
if (file_exists(getcwd().DIRECTORY_SEPARATOR.".tmp_behatFormatter".DIRECTORY_SEPARATOR.$screenshot)){
754-
$screenshot = 'assets'.DIRECTORY_SEPARATOR.'screenshots'.DIRECTORY_SEPARATOR.$screenshot;
755-
$step->setScreenshot($screenshot);
756-
}
757-
}
757+
758758
$this->currentScenario->addStep($step);
759759

760760
$print = $this->renderer->renderAfterStep($this);

0 commit comments

Comments
 (0)