Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Tester / Runtime / RuntimeOutlineTester.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\FeatureNode;
16 use Behat\Gherkin\Node\OutlineNode;
17 use Behat\Testwork\Environment\Environment;
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
25 /**
26  * Tester executing outline tests in the runtime.
27  *
28  * @author Konstantin Kudryashov <ever.zet@gmail.com>
29  */
30 final class RuntimeOutlineTester implements OutlineTester
31 {
32     /**
33      * @var ScenarioTester
34      */
35     private $scenarioTester;
36
37     /**
38      * Initializes tester.
39      *
40      * @param ScenarioTester $scenarioTester
41      */
42     public function __construct(ScenarioTester $scenarioTester)
43     {
44         $this->scenarioTester = $scenarioTester;
45     }
46
47     /**
48      * {@inheritdoc}
49      */
50     public function setUp(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip)
51     {
52         return new SuccessfulSetup();
53     }
54
55     /**
56      * {@inheritdoc}
57      */
58     public function test(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip = false)
59     {
60         $results = array();
61         foreach ($outline->getExamples() as $example) {
62             $setup = $this->scenarioTester->setUp($env, $feature, $example, $skip);
63             $localSkip = !$setup->isSuccessful() || $skip;
64             $testResult = $this->scenarioTester->test($env, $feature, $example, $localSkip);
65             $teardown = $this->scenarioTester->tearDown($env, $feature, $example, $localSkip, $testResult);
66
67             $integerResult = new IntegerTestResult($testResult->getResultCode());
68             $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
69         }
70
71         return new TestResults($results);
72     }
73
74     /**
75      * {@inheritdoc}
76      */
77     public function tearDown(Environment $env, FeatureNode $feature, OutlineNode $outline, $skip, TestResult $result)
78     {
79         return new SuccessfulTeardown();
80     }
81 }