Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Tester / StepContainerTester.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;
12
13 use Behat\Gherkin\Node\FeatureNode;
14 use Behat\Gherkin\Node\StepContainerInterface;
15 use Behat\Testwork\Environment\Environment;
16 use Behat\Testwork\Tester\Result\IntegerTestResult;
17 use Behat\Testwork\Tester\Result\TestResult;
18 use Behat\Testwork\Tester\Result\TestWithSetupResult;
19
20 /**
21  * Tests provided collection of steps against provided environment.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class StepContainerTester
26 {
27     /**
28      * @var StepTester
29      */
30     private $stepTester;
31
32     /**
33      * Initializes tester.
34      *
35      * @param StepTester $stepTester
36      */
37     public function __construct(StepTester $stepTester)
38     {
39         $this->stepTester = $stepTester;
40     }
41
42     /**
43      * Tests container.
44      *
45      * @param Environment            $env
46      * @param FeatureNode            $feature
47      * @param StepContainerInterface $container
48      * @param Boolean                $skip
49      *
50      * @return TestResult[]
51      */
52     public function test(Environment $env, FeatureNode $feature, StepContainerInterface $container, $skip)
53     {
54         $results = array();
55         foreach ($container->getSteps() as $step) {
56             $setup = $this->stepTester->setUp($env, $feature, $step, $skip);
57             $skipSetup = !$setup->isSuccessful() || $skip;
58
59             $testResult = $this->stepTester->test($env, $feature, $step, $skipSetup);
60             $skip = !$testResult->isPassed() || $skip;
61
62             $teardown = $this->stepTester->tearDown($env, $feature, $step, $skipSetup, $testResult);
63             $skip = $skip || $skipSetup || !$teardown->isSuccessful();
64
65             $integerResult = new IntegerTestResult($testResult->getResultCode());
66             $results[] = new TestWithSetupResult($setup, $integerResult, $teardown);
67         }
68
69         return $results;
70     }
71 }