Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Tester / Runtime / RuntimeFeatureTester.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\OutlineTester;
14 use Behat\Behat\Tester\ScenarioTester;
15 use Behat\Gherkin\Node\OutlineNode;
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\TestResults;
21 use Behat\Testwork\Tester\Result\TestWithSetupResult;
22 use Behat\Testwork\Tester\Setup\SuccessfulSetup;
23 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
24 use Behat\Testwork\Tester\SpecificationTester;
25
26 /**
27  * Tester executing feature tests in the runtime.
28  *
29  * @author Konstantin Kudryashov <ever.zet@gmail.com>
30  */
31 final class RuntimeFeatureTester implements SpecificationTester
32 {
33     /**
34      * @var ScenarioTester
35      */
36     private $scenarioTester;
37     /**
38      * @var OutlineTester
39      */
40     private $outlineTester;
41     /**
42      * @var EnvironmentManager
43      */
44     private $envManager;
45
46     /**
47      * Initializes tester.
48      *
49      * @param ScenarioTester     $scenarioTester
50      * @param OutlineTester      $outlineTester
51      * @param EnvironmentManager $envManager
52      *
53      * TODO: Remove EnvironmentManager parameter in next major
54      */
55     public function __construct(
56         ScenarioTester $scenarioTester,
57         OutlineTester $outlineTester,
58         EnvironmentManager $envManager
59     ) {
60         $this->scenarioTester = $scenarioTester;
61         $this->outlineTester = $outlineTester;
62         $this->envManager = $envManager;
63     }
64
65     /**
66      * {@inheritdoc}
67      */
68     public function setUp(Environment $env, $spec, $skip)
69     {
70         return new SuccessfulSetup();
71     }
72
73     /**
74      * {@inheritdoc}
75      */
76     public function test(Environment $env, $feature, $skip = false)
77     {
78         $results = array();
79         foreach ($feature->getScenarios() as $scenario) {
80             $tester = $scenario instanceof OutlineNode ? $this->outlineTester : $this->scenarioTester;
81
82             $setup = $tester->setUp($env, $feature, $scenario, $skip);
83             $localSkip = !$setup->isSuccessful() || $skip;
84             $testResult = $tester->test($env, $feature, $scenario, $localSkip);
85             $teardown = $tester->tearDown($env, $feature, $scenario, $localSkip, $testResult);
86
87             $integerResult = new IntegerTestResult($testResult->getResultCode());
88             $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
89         }
90
91         return new TestResults($results);
92     }
93
94     /**
95      * {@inheritdoc}
96      */
97     public function tearDown(Environment $env, $spec, $skip, TestResult $result)
98     {
99         return new SuccessfulTeardown();
100     }
101 }