Passed
Pull Request — master (#9)
by Rafael
03:29
created

ContextLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 41
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 3 1
A __construct() 0 4 1
A setUp() 0 8 2
A test() 0 3 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
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 Ynlo\GraphQLBundle\Behat\Context\Loader;
12
13
use Behat\Behat\Context\Environment\UninitializedContextEnvironment;
14
use Behat\Testwork\Environment\Environment;
15
use Behat\Testwork\Specification\SpecificationIterator;
16
use Behat\Testwork\Tester\Result\TestResult;
17
use Behat\Testwork\Tester\SuiteTester;
18
19
/**
20
 * Auto-load all API contexts
21
 *
22
 * @TODO: add some flat to only register for suites tagged with @api
23
 */
24
class ContextLoader implements SuiteTester
25
{
26
    /**
27
     * @var SuiteTester
28
     */
29
    protected $baseTester;
30
31
    /**
32
     * @var string[]
33
     */
34
    protected $contexts = [];
35
36
    /**
37
     * ContextAutoLoader constructor.
38
     *
39
     * @param SuiteTester $baseTester
40
     */
41
    public function __construct(SuiteTester $baseTester, $contexts = [])
42
    {
43
        $this->baseTester = $baseTester;
44
        $this->contexts = $contexts;
45
    }
46
47
    public function setUp(Environment $env, SpecificationIterator $iterator, $skip)
48
    {
49
        /** @var UninitializedContextEnvironment $env */
50
        foreach ($this->contexts as $context) {
51
            $env->registerContextClass($context);
52
        }
53
54
        return $this->baseTester->setUp($env, $iterator, $skip);
55
    }
56
57
    public function test(Environment $env, SpecificationIterator $iterator, $skip)
58
    {
59
        return $this->baseTester->test($env, $iterator, $skip);
60
    }
61
62
    public function tearDown(Environment $env, SpecificationIterator $iterator, $skip, TestResult $result)
63
    {
64
        return $this->baseTester->tearDown($env, $iterator, $skip, $result);
65
    }
66
}
67