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\AfterTested;
19 use Behat\Testwork\Tester\Result\ExceptionResult;
20 use Behat\Testwork\Tester\Result\TestResult;
21 use Behat\Testwork\Tester\Setup\Teardown;
24 * Represents an event after step has been tested.
26 * @author Konstantin Kudryashov <ever.zet@gmail.com>
28 final class AfterStepTested extends StepTested implements AfterTested
50 * @param Environment $env
51 * @param FeatureNode $feature
52 * @param StepNode $step
53 * @param StepResult $result
54 * @param Teardown $teardown
56 public function __construct(
63 parent::__construct($env);
65 $this->feature = $feature;
67 $this->result = $result;
68 $this->teardown = $teardown;
76 public function getFeature()
78 return $this->feature;
86 public function getStep()
92 * Returns current test result.
96 public function getTestResult()
102 * Returns current test teardown.
106 public function getTeardown()
108 return $this->teardown;
112 * Checks if step call, setup or teardown produced any output (stdOut or exception).
116 public function hasOutput()
118 return $this->teardownHasOutput() || $this->resultHasException() || $this->resultCallHasOutput();
122 * Checks if step teardown has output.
126 private function teardownHasOutput()
128 return $this->teardown->hasOutput();
132 * Checks if result has produced exception.
136 private function resultHasException()
138 return $this->result instanceof ExceptionResult && $this->result->getException();
142 * Checks if result is executed and call result has produced exception or stdOut.
146 private function resultCallHasOutput()
148 if (!$this->result instanceof ExecutedStepResult) {
152 return $this->result->getCallResult()->hasStdOut() || $this->result->getCallResult()->hasException();