4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\EventDispatcher\Event;
13 use Behat\Behat\Tester\Result\ExecutedStepResult;
14 use Behat\Behat\Tester\Result\StepResult;
15 use Behat\Gherkin\Node\FeatureNode;
16 use Behat\Gherkin\Node\StepNode;
17 use Behat\Testwork\Environment\Environment;
18 use Behat\Testwork\EventDispatcher\Event\BeforeTeardown;
19 use Behat\Testwork\Tester\Result\ExceptionResult;
20 use Behat\Testwork\Tester\Result\TestResult;
23 * Represents an event before step teardown.
25 * @author Konstantin Kudryashov <ever.zet@gmail.com>
27 final class BeforeStepTeardown extends StepTested implements BeforeTeardown
45 * @param Environment $env
46 * @param FeatureNode $feature
47 * @param StepNode $step
48 * @param StepResult $result
50 public function __construct(
56 parent::__construct($env);
58 $this->feature = $feature;
60 $this->result = $result;
68 public function getFeature()
70 return $this->feature;
78 public function getStep()
84 * Returns current test result.
88 public function getTestResult()
94 * Checks if step call produced any output (stdOut or exception).
98 public function hasOutput()
100 return $this->resultHasException() || $this->resultCallHasOutput();
104 * Checks if result has produced exception.
108 private function resultHasException()
110 return $this->result instanceof ExceptionResult && $this->result->getException();
114 * Checks if result is executed and call result has produced exception or stdOut.
118 private function resultCallHasOutput()
120 if (!$this->result instanceof ExecutedStepResult) {
124 return $this->result->getCallResult()->hasStdOut() || $this->result->getCallResult()->hasException();