ContainerAwareTestCase   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 86
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 1
A getContainer() 0 4 1
A setContainer() 0 4 1
A getConfigManager() 0 4 1
A setConfigManager() 0 4 1
A getConfig() 0 4 1
1
<?php
2
/**
3
 * Reddogs (https://github.com/reddogs-at)
4
 *
5
 * @see https://github.com/reddogs-at/reddogs-test for the canonical source repository
6
 * @license https://github.com/reddogs-at/reddogs-test/blob/master/LICENSE MIT License
7
 */
8
namespace Reddogs\Test;
9
10
use Interop\Container\ContainerInterface;
11
use Zend\Expressive\ConfigManager\ConfigManager;
12
use Zend\ServiceManager\ServiceManager;
13
use Zend\ServiceManager\Config;
14
15
/**
16
 * Container aware testcase
17
 *
18
 * @deprecated
19
 */
20
abstract class ContainerAwareTestCase extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * Container
24
     *
25
     * @var ContainerInterface
26
     */
27
    private $container;
28
29
    /**
30
     * Config manager
31
     *
32
     * @var ConfigManager
33
     */
34
    private $configManager;
35
36
    /**
37
     * Config manager
38
     *
39
     * {@inheritdoc}
40
     *
41
     * @see PHPUnit_Framework_TestCase::setUp()
42
     */
43
    protected function setUp()
44
    {
45
        parent::setUp();
46
47
        $config = new \ArrayObject($this->getConfigManager()->getMergedConfig());
48
        $container = new ServiceManager();
49
        (new Config($config['dependencies']))->configureServiceManager($container);
50
51
        $container->setService('config', $config);
52
53
        $this->setContainer($container);
54
    }
55
56
    /**
57
     * Get container
58
     *
59
     * @return ContainerInterface
60
     */
61
    public function getContainer()
62
    {
63
        return $this->container;
64
    }
65
66
    /**
67
     * Set container
68
     *
69
     * @param ContainerInterface $container
70
     */
71
    public function setContainer(ContainerInterface $container)
72
    {
73
        $this->container = $container;
74
    }
75
76
    /**
77
     * Get config manager
78
     *
79
     * @return ConfigManager
80
     */
81
    public function getConfigManager()
82
    {
83
        return $this->configManager;
84
    }
85
86
    /**
87
     * Set config manager
88
     *
89
     * @param ConfigManager $configManager
90
     */
91
    public function setConfigManager(ConfigManager $configManager)
92
    {
93
        $this->configManager = $configManager;
94
    }
95
96
    /**
97
     * Get config
98
     *
99
     * @return array
100
     */
101
    public function getConfig()
102
    {
103
        return $this->getContainer()->get('config');
104
    }
105
}