Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Tester / Runtime / RuntimeSuiteTester.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
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\Runtime;
12
13 use Behat\Testwork\Environment\Environment;
14 use Behat\Testwork\Specification\SpecificationIterator;
15 use Behat\Testwork\Tester\Result\IntegerTestResult;
16 use Behat\Testwork\Tester\Result\TestResult;
17 use Behat\Testwork\Tester\Result\TestResults;
18 use Behat\Testwork\Tester\Result\TestWithSetupResult;
19 use Behat\Testwork\Tester\Setup\SuccessfulSetup;
20 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
21 use Behat\Testwork\Tester\SpecificationTester;
22 use Behat\Testwork\Tester\SuiteTester;
23
24 /**
25  * Tester executing suite tests in the runtime.
26  *
27  * @author Konstantin Kudryashov <ever.zet@gmail.com>
28  */
29 final class RuntimeSuiteTester implements SuiteTester
30 {
31     /**
32      * @var SpecificationTester
33      */
34     private $specTester;
35
36     /**
37      * Initializes tester.
38      *
39      * @param SpecificationTester $specTester
40      */
41     public function __construct(SpecificationTester $specTester)
42     {
43         $this->specTester = $specTester;
44     }
45
46     /**
47      * {@inheritdoc}
48      */
49     public function setUp(Environment $env, SpecificationIterator $iterator, $skip)
50     {
51         return new SuccessfulSetup();
52     }
53
54     /**
55      * {@inheritdoc}
56      */
57     public function test(Environment $env, SpecificationIterator $iterator, $skip = false)
58     {
59         $results = array();
60         foreach ($iterator as $specification) {
61             $setup = $this->specTester->setUp($env, $specification, $skip);
62             $localSkip = !$setup->isSuccessful() || $skip;
63             $testResult = $this->specTester->test($env, $specification, $localSkip);
64             $teardown = $this->specTester->tearDown($env, $specification, $localSkip, $testResult);
65
66             $integerResult = new IntegerTestResult($testResult->getResultCode());
67             $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
68         }
69
70         return new TestResults($results);
71     }
72
73     /**
74      * {@inheritdoc}
75      */
76     public function tearDown(Environment $env, SpecificationIterator $iterator, $skip, TestResult $result)
77     {
78         return new SuccessfulTeardown();
79     }
80 }