Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Tester / Result / ExecutedStepResult.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat\Tester\Result;
12
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;
17
18 /**
19  * Represents an executed (successfully or not) step result.
20  *
21  * @author Konstantin Kudryashov <ever.zet@gmail.com>
22  */
23 final class ExecutedStepResult implements StepResult, DefinedStepResult, ExceptionResult
24 {
25     /**
26      * @var SearchResult
27      */
28     private $searchResult;
29     /**
30      * @var null|CallResult
31      */
32     private $callResult;
33
34     /**
35      * Initialize test result.
36      *
37      * @param SearchResult $searchResult
38      * @param CallResult   $callResult
39      */
40     public function __construct(SearchResult $searchResult, CallResult $callResult)
41     {
42         $this->searchResult = $searchResult;
43         $this->callResult = $callResult;
44     }
45
46     /**
47      * Returns definition search result.
48      *
49      * @return SearchResult
50      */
51     public function getSearchResult()
52     {
53         return $this->searchResult;
54     }
55
56     /**
57      * Returns definition call result or null if no call were made.
58      *
59      * @return CallResult
60      */
61     public function getCallResult()
62     {
63         return $this->callResult;
64     }
65
66     /**
67      * {@inheritdoc}
68      */
69     public function getStepDefinition()
70     {
71         return $this->searchResult->getMatchedDefinition();
72     }
73
74     /**
75      * {@inheritdoc}
76      */
77     public function hasException()
78     {
79         return null !== $this->getException();
80     }
81
82     /**
83      * {@inheritdoc}
84      */
85     public function getException()
86     {
87         return $this->callResult->getException();
88     }
89
90     /**
91      * {@inheritdoc}
92      */
93     public function getResultCode()
94     {
95         if ($this->callResult->hasException() && $this->callResult->getException() instanceof PendingException) {
96             return self::PENDING;
97         }
98
99         if ($this->callResult->hasException()) {
100             return self::FAILED;
101         }
102
103         return self::PASSED;
104     }
105
106     /**
107      * {@inheritdoc}
108      */
109     public function isPassed()
110     {
111         return self::PASSED == $this->getResultCode();
112     }
113 }