Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Tester / Runtime / RuntimeBackgroundTester.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\BackgroundTester;
14 use Behat\Behat\Tester\Exception\FeatureHasNoBackgroundException;
15 use Behat\Behat\Tester\StepContainerTester;
16 use Behat\Gherkin\Node\FeatureNode;
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\Setup\SuccessfulSetup;
22 use Behat\Testwork\Tester\Setup\SuccessfulTeardown;
23
24 /**
25  * Tester executing background tests in the runtime.
26  *
27  * @author Konstantin Kudryashov <ever.zet@gmail.com>
28  */
29 final class RuntimeBackgroundTester implements BackgroundTester
30 {
31     /**
32      * @var StepContainerTester
33      */
34     private $containerTester;
35
36     /**
37      * Initializes tester.
38      *
39      * @param StepContainerTester $containerTester
40      */
41     public function __construct(StepContainerTester $containerTester)
42     {
43         $this->containerTester = $containerTester;
44     }
45
46     /**
47      * {@inheritdoc}
48      */
49     public function setUp(Environment $env, FeatureNode $feature, $skip)
50     {
51         return new SuccessfulSetup();
52     }
53
54     /**
55      * {@inheritdoc}
56      */
57     public function test(Environment $env, FeatureNode $feature, $skip)
58     {
59         $background = $feature->getBackground();
60
61         if (null === $background) {
62             throw new FeatureHasNoBackgroundException(sprintf(
63                 'Feature `%s` has no background that could be tested.',
64                 $feature->getFile()
65             ), $feature);
66         }
67
68         if (!$background->hasSteps()) {
69             return new IntegerTestResult(TestResult::PASSED);
70         }
71
72         $results = $this->containerTester->test($env, $feature, $background, $skip);
73
74         return new TestResults($results);
75     }
76
77     /**
78      * {@inheritdoc}
79      */
80     public function tearDown(Environment $env, FeatureNode $feature, $skip, TestResult $result)
81     {
82         return new SuccessfulTeardown();
83     }
84 }