Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Tester / Result / TestWithSetupResult.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\Testwork\Tester\Result;
12
13 use Behat\Testwork\Tester\Setup\Setup;
14 use Behat\Testwork\Tester\Setup\Teardown;
15
16 /**
17  * Represents a test result with both setup and teardown attached.
18  *
19  * @author Konstantin Kudryashov <ever.zet@gmail.com>
20  */
21 final class TestWithSetupResult implements TestResult
22 {
23     /**
24      * @var Setup
25      */
26     private $setup;
27     /**
28      * @var TestResult
29      */
30     private $result;
31     /**
32      * @var Teardown
33      */
34     private $teardown;
35
36     /**
37      * Initializes test result.
38      *
39      * @param Setup      $setup
40      * @param TestResult $result
41      * @param Teardown   $teardown
42      */
43     public function __construct(Setup $setup, TestResult $result, Teardown $teardown)
44     {
45         $this->setup = $setup;
46         $this->result = $result;
47         $this->teardown = $teardown;
48     }
49
50     /**
51      * {@inheritdoc}
52      */
53     public function isPassed()
54     {
55         return self::PASSED == $this->getResultCode();
56     }
57
58     /**
59      * {@inheritdoc}
60      */
61     public function getResultCode()
62     {
63         if (!$this->setup->isSuccessful()) {
64             return self::FAILED;
65         }
66
67         if (!$this->teardown->isSuccessful()) {
68             return self::FAILED;
69         }
70
71         return $this->result->getResultCode();
72     }
73 }