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\Tester\Result;
13 use Behat\Behat\Definition\SearchResult;
14 use Behat\Behat\Tester\Exception\PendingException;
15 use Behat\Testwork\Call\CallResult;
16 use Behat\Testwork\Tester\Result\ExceptionResult;
19 * Represents an executed (successfully or not) step result.
21 * @author Konstantin Kudryashov <ever.zet@gmail.com>
23 final class ExecutedStepResult implements StepResult, DefinedStepResult, ExceptionResult
28 private $searchResult;
30 * @var null|CallResult
35 * Initialize test result.
37 * @param SearchResult $searchResult
38 * @param CallResult $callResult
40 public function __construct(SearchResult $searchResult, CallResult $callResult)
42 $this->searchResult = $searchResult;
43 $this->callResult = $callResult;
47 * Returns definition search result.
49 * @return SearchResult
51 public function getSearchResult()
53 return $this->searchResult;
57 * Returns definition call result or null if no call were made.
61 public function getCallResult()
63 return $this->callResult;
69 public function getStepDefinition()
71 return $this->searchResult->getMatchedDefinition();
77 public function hasException()
79 return null !== $this->getException();
85 public function getException()
87 return $this->callResult->getException();
93 public function getResultCode()
95 if ($this->callResult->hasException() && $this->callResult->getException() instanceof PendingException) {
99 if ($this->callResult->hasException()) {
109 public function isPassed()
111 return self::PASSED == $this->getResultCode();