ZfTestCaseAwareInitializer::initializeContext()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of the Noiselabs ZfTestCase Behat Extension.
4
 *
5
 * (c) Vítor Brandão <[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 Noiselabs\Behat\ZfTestCaseExtension\Context\Initializer;
12
13
use Behat\Behat\Context\Context;
14
use Behat\Behat\Context\Initializer\ContextInitializer;
15
use Noiselabs\Behat\ZfTestCaseExtension\Context\ZfTestCaseAwareContext;
16
use Noiselabs\Behat\ZfTestCaseExtension\TestCase\HttpControllerTestCase;
17
18
/**
19
 * ZfTestCase aware contexts initializer.
20
 * Sets an HttpControllerTestCase instance to ZfTestCaseAware contexts.
21
 */
22
class ZfTestCaseAwareInitializer implements ContextInitializer
23
{
24
    /**
25
     * @var HttpControllerTestCase
26
     */
27
    private $testCase;
28
29
    public function __construct(HttpControllerTestCase $testCase)
30
    {
31
        $this->testCase = $testCase;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function initializeContext(Context $context)
38
    {
39
        if ($context instanceof ZfTestCaseAwareContext) {
40
            $context->setTestCase($this->testCase);
41
        }
42
    }
43
}