Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Tester / Runtime / IsolatingScenarioTester.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\Runtime;
12
13 use Behat\Behat\Tester\ScenarioTester;
14 use Behat\Gherkin\Node\FeatureNode;
15 use Behat\Gherkin\Node\ScenarioInterface as Scenario;
16 use Behat\Testwork\Environment\Environment;
17 use Behat\Testwork\Environment\EnvironmentManager;
18 use Behat\Testwork\Tester\Result\IntegerTestResult;
19 use Behat\Testwork\Tester\Result\TestResult;
20 use Behat\Testwork\Tester\Result\TestWithSetupResult;
21 use Behat\Testwork\Tester\Setup\SuccessfulSetup;
22 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
23
24 /**
25  * Scenario tester that isolates the environment for each scenario.
26  *
27  * @author Konstantin Kudryashov <ever.zet@gmail.com>
28  */
29 final class IsolatingScenarioTester implements ScenarioTester
30 {
31     /**
32      * @var ScenarioTester
33      */
34     private $decoratedTester;
35     /**
36      * @var EnvironmentManager
37      */
38     private $envManager;
39
40     /**
41      * Initialises tester.
42      *
43      * @param ScenarioTester     $decoratedTester
44      * @param EnvironmentManager $envManager
45      */
46     public function __construct(ScenarioTester $decoratedTester, EnvironmentManager $envManager)
47     {
48         $this->decoratedTester = $decoratedTester;
49         $this->envManager = $envManager;
50     }
51
52     /**
53      * {@inheritdoc}
54      */
55     public function setUp(Environment $env, FeatureNode $feature, Scenario $scenario, $skip)
56     {
57         return new SuccessfulSetup();
58     }
59
60     /**
61      * {@inheritdoc}
62      */
63     public function test(Environment $env, FeatureNode $feature, Scenario $scenario, $skip)
64     {
65         $isolatedEnvironment = $this->envManager->isolateEnvironment($env, $scenario);
66
67         $setup = $this->decoratedTester->setUp($isolatedEnvironment, $feature, $scenario, $skip);
68         $localSkip = !$setup->isSuccessful() || $skip;
69         $testResult = $this->decoratedTester->test($isolatedEnvironment, $feature, $scenario, $localSkip);
70         $teardown = $this->decoratedTester->tearDown($isolatedEnvironment, $feature, $scenario, $localSkip, $testResult);
71
72         $integerResult = new IntegerTestResult($testResult->getResultCode());
73
74         return new TestWithSetupResult($setup, $integerResult, $teardown);
75     }
76
77     /**
78      * {@inheritdoc}
79      */
80     public function tearDown(Environment $env, FeatureNode $feature, Scenario $scenario, $skip, TestResult $result)
81     {
82         return new SuccessfulTeardown();
83     }
84 }